@fluentui/react-field 9.0.0-alpha.1 → 9.0.0-alpha.10

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 (149) hide show
  1. package/CHANGELOG.json +630 -1
  2. package/CHANGELOG.md +164 -2
  3. package/dist/index.d.ts +30 -95
  4. package/lib/Field.js.map +1 -1
  5. package/lib/components/Field/Field.types.js.map +1 -1
  6. package/lib/components/Field/SlotComponent.types.js.map +1 -1
  7. package/lib/components/Field/index.js.map +1 -1
  8. package/lib/components/Field/renderField.js.map +1 -1
  9. package/lib/components/Field/useField.js +30 -25
  10. package/lib/components/Field/useField.js.map +1 -1
  11. package/lib/components/Field/useFieldStyles.js +3 -3
  12. package/lib/components/Field/useFieldStyles.js.map +1 -1
  13. package/lib/index.js +0 -9
  14. package/lib/index.js.map +1 -1
  15. package/lib-amd/Field.js +6 -0
  16. package/lib-amd/Field.js.map +1 -0
  17. package/lib-amd/components/Field/Field.types.js +5 -0
  18. package/lib-amd/components/Field/Field.types.js.map +1 -0
  19. package/lib-amd/components/Field/SlotComponent.types.js +5 -0
  20. package/lib-amd/components/Field/SlotComponent.types.js.map +1 -0
  21. package/lib-amd/components/Field/index.js +9 -0
  22. package/lib-amd/components/Field/index.js.map +1 -0
  23. package/lib-amd/components/Field/renderField.js +20 -0
  24. package/lib-amd/components/Field/renderField.js.map +1 -0
  25. package/lib-amd/components/Field/useField.js +119 -0
  26. package/lib-amd/components/Field/useField.js.map +1 -0
  27. package/lib-amd/components/Field/useFieldStyles.js +97 -0
  28. package/lib-amd/components/Field/useFieldStyles.js.map +1 -0
  29. package/lib-amd/index.js +10 -0
  30. package/lib-amd/index.js.map +1 -0
  31. package/lib-commonjs/Field.js.map +1 -1
  32. package/lib-commonjs/components/Field/index.js.map +1 -1
  33. package/lib-commonjs/components/Field/renderField.js.map +1 -1
  34. package/lib-commonjs/components/Field/useField.js +30 -25
  35. package/lib-commonjs/components/Field/useField.js.map +1 -1
  36. package/lib-commonjs/components/Field/useFieldStyles.js +4 -4
  37. package/lib-commonjs/components/Field/useFieldStyles.js.map +1 -1
  38. package/lib-commonjs/index.js +1 -136
  39. package/lib-commonjs/index.js.map +1 -1
  40. package/package.json +22 -24
  41. package/Spec.md +0 -354
  42. package/lib/CheckboxField.js +0 -2
  43. package/lib/CheckboxField.js.map +0 -1
  44. package/lib/ComboboxField.js +0 -2
  45. package/lib/ComboboxField.js.map +0 -1
  46. package/lib/InputField.js +0 -2
  47. package/lib/InputField.js.map +0 -1
  48. package/lib/RadioGroupField.js +0 -2
  49. package/lib/RadioGroupField.js.map +0 -1
  50. package/lib/SelectField.js +0 -2
  51. package/lib/SelectField.js.map +0 -1
  52. package/lib/SliderField.js +0 -2
  53. package/lib/SliderField.js.map +0 -1
  54. package/lib/SpinButtonField.js +0 -2
  55. package/lib/SpinButtonField.js.map +0 -1
  56. package/lib/SwitchField.js +0 -2
  57. package/lib/SwitchField.js.map +0 -1
  58. package/lib/TextareaField.js +0 -2
  59. package/lib/TextareaField.js.map +0 -1
  60. package/lib/components/CheckboxField/CheckboxField.js +0 -32
  61. package/lib/components/CheckboxField/CheckboxField.js.map +0 -1
  62. package/lib/components/CheckboxField/index.js +0 -2
  63. package/lib/components/CheckboxField/index.js.map +0 -1
  64. package/lib/components/ComboboxField/ComboboxField.js +0 -14
  65. package/lib/components/ComboboxField/ComboboxField.js.map +0 -1
  66. package/lib/components/ComboboxField/index.js +0 -2
  67. package/lib/components/ComboboxField/index.js.map +0 -1
  68. package/lib/components/InputField/InputField.js +0 -14
  69. package/lib/components/InputField/InputField.js.map +0 -1
  70. package/lib/components/InputField/index.js +0 -2
  71. package/lib/components/InputField/index.js.map +0 -1
  72. package/lib/components/RadioGroupField/RadioGroupField.js +0 -15
  73. package/lib/components/RadioGroupField/RadioGroupField.js.map +0 -1
  74. package/lib/components/RadioGroupField/index.js +0 -2
  75. package/lib/components/RadioGroupField/index.js.map +0 -1
  76. package/lib/components/SelectField/SelectField.js +0 -14
  77. package/lib/components/SelectField/SelectField.js.map +0 -1
  78. package/lib/components/SelectField/index.js +0 -2
  79. package/lib/components/SelectField/index.js.map +0 -1
  80. package/lib/components/SliderField/SliderField.js +0 -14
  81. package/lib/components/SliderField/SliderField.js.map +0 -1
  82. package/lib/components/SliderField/index.js +0 -2
  83. package/lib/components/SliderField/index.js.map +0 -1
  84. package/lib/components/SpinButtonField/SpinButtonField.js +0 -14
  85. package/lib/components/SpinButtonField/SpinButtonField.js.map +0 -1
  86. package/lib/components/SpinButtonField/index.js +0 -2
  87. package/lib/components/SpinButtonField/index.js.map +0 -1
  88. package/lib/components/SwitchField/SwitchField.js +0 -14
  89. package/lib/components/SwitchField/SwitchField.js.map +0 -1
  90. package/lib/components/SwitchField/index.js +0 -2
  91. package/lib/components/SwitchField/index.js.map +0 -1
  92. package/lib/components/TextareaField/TextareaField.js +0 -14
  93. package/lib/components/TextareaField/TextareaField.js.map +0 -1
  94. package/lib/components/TextareaField/index.js +0 -2
  95. package/lib/components/TextareaField/index.js.map +0 -1
  96. package/lib-commonjs/CheckboxField.js +0 -10
  97. package/lib-commonjs/CheckboxField.js.map +0 -1
  98. package/lib-commonjs/ComboboxField.js +0 -10
  99. package/lib-commonjs/ComboboxField.js.map +0 -1
  100. package/lib-commonjs/InputField.js +0 -10
  101. package/lib-commonjs/InputField.js.map +0 -1
  102. package/lib-commonjs/RadioGroupField.js +0 -10
  103. package/lib-commonjs/RadioGroupField.js.map +0 -1
  104. package/lib-commonjs/SelectField.js +0 -10
  105. package/lib-commonjs/SelectField.js.map +0 -1
  106. package/lib-commonjs/SliderField.js +0 -10
  107. package/lib-commonjs/SliderField.js.map +0 -1
  108. package/lib-commonjs/SpinButtonField.js +0 -10
  109. package/lib-commonjs/SpinButtonField.js.map +0 -1
  110. package/lib-commonjs/SwitchField.js +0 -10
  111. package/lib-commonjs/SwitchField.js.map +0 -1
  112. package/lib-commonjs/TextareaField.js +0 -10
  113. package/lib-commonjs/TextareaField.js.map +0 -1
  114. package/lib-commonjs/components/CheckboxField/CheckboxField.js +0 -42
  115. package/lib-commonjs/components/CheckboxField/CheckboxField.js.map +0 -1
  116. package/lib-commonjs/components/CheckboxField/index.js +0 -10
  117. package/lib-commonjs/components/CheckboxField/index.js.map +0 -1
  118. package/lib-commonjs/components/ComboboxField/ComboboxField.js +0 -24
  119. package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +0 -1
  120. package/lib-commonjs/components/ComboboxField/index.js +0 -10
  121. package/lib-commonjs/components/ComboboxField/index.js.map +0 -1
  122. package/lib-commonjs/components/InputField/InputField.js +0 -24
  123. package/lib-commonjs/components/InputField/InputField.js.map +0 -1
  124. package/lib-commonjs/components/InputField/index.js +0 -10
  125. package/lib-commonjs/components/InputField/index.js.map +0 -1
  126. package/lib-commonjs/components/RadioGroupField/RadioGroupField.js +0 -25
  127. package/lib-commonjs/components/RadioGroupField/RadioGroupField.js.map +0 -1
  128. package/lib-commonjs/components/RadioGroupField/index.js +0 -10
  129. package/lib-commonjs/components/RadioGroupField/index.js.map +0 -1
  130. package/lib-commonjs/components/SelectField/SelectField.js +0 -24
  131. package/lib-commonjs/components/SelectField/SelectField.js.map +0 -1
  132. package/lib-commonjs/components/SelectField/index.js +0 -10
  133. package/lib-commonjs/components/SelectField/index.js.map +0 -1
  134. package/lib-commonjs/components/SliderField/SliderField.js +0 -24
  135. package/lib-commonjs/components/SliderField/SliderField.js.map +0 -1
  136. package/lib-commonjs/components/SliderField/index.js +0 -10
  137. package/lib-commonjs/components/SliderField/index.js.map +0 -1
  138. package/lib-commonjs/components/SpinButtonField/SpinButtonField.js +0 -24
  139. package/lib-commonjs/components/SpinButtonField/SpinButtonField.js.map +0 -1
  140. package/lib-commonjs/components/SpinButtonField/index.js +0 -10
  141. package/lib-commonjs/components/SpinButtonField/index.js.map +0 -1
  142. package/lib-commonjs/components/SwitchField/SwitchField.js +0 -24
  143. package/lib-commonjs/components/SwitchField/SwitchField.js.map +0 -1
  144. package/lib-commonjs/components/SwitchField/index.js +0 -10
  145. package/lib-commonjs/components/SwitchField/index.js.map +0 -1
  146. package/lib-commonjs/components/TextareaField/TextareaField.js +0 -24
  147. package/lib-commonjs/components/TextareaField/TextareaField.js.map +0 -1
  148. package/lib-commonjs/components/TextareaField/index.js +0 -10
  149. package/lib-commonjs/components/TextareaField/index.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,12 +1,174 @@
1
1
  # Change Log - @fluentui/react-field
2
2
 
3
- This log was last generated on Thu, 15 Sep 2022 09:44:25 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 05 Dec 2022 18:25:21 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-alpha.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.10)
8
+
9
+ Mon, 05 Dec 2022 18:25:21 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.9..@fluentui/react-field_v9.0.0-alpha.10)
11
+
12
+ ### Changes
13
+
14
+ - fix: Field should use aria-describedby instead of aria-errormessage ([PR #25580](https://github.com/microsoft/fluentui/pull/25580) by behowell@microsoft.com)
15
+ - chore: Migrate to new package structure. ([PR #25817](https://github.com/microsoft/fluentui/pull/25817) by tristan.watanabe@gmail.com)
16
+ - Bump @fluentui/react-label to v9.0.12 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
17
+ - Bump @fluentui/react-theme to v9.1.3 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
18
+
19
+ ## [9.0.0-alpha.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.9)
20
+
21
+ Thu, 17 Nov 2022 23:05:39 GMT
22
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.8..@fluentui/react-field_v9.0.0-alpha.9)
23
+
24
+ ### Changes
25
+
26
+ - Bump @fluentui/react-context-selector to v9.1.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
27
+ - Bump @fluentui/react-label to v9.0.11 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
28
+ - Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
29
+
30
+ ## [9.0.0-alpha.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.8)
31
+
32
+ Fri, 11 Nov 2022 14:58:03 GMT
33
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.7..@fluentui/react-field_v9.0.0-alpha.8)
34
+
35
+ ### Changes
36
+
37
+ - fix: create valid export maps ([PR #25558](https://github.com/microsoft/fluentui/pull/25558) by martinhochel@microsoft.com)
38
+ - chore: Clean up Field tests and story imports in preparation of moving to individual packages ([PR #25594](https://github.com/microsoft/fluentui/pull/25594) by behowell@microsoft.com)
39
+ - chore: Move individual field components into their respective packages, and out of @fluentui/react-field ([PR #25593](https://github.com/microsoft/fluentui/pull/25593) by behowell@microsoft.com)
40
+ - Bump @fluentui/react-context-selector to v9.1.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
41
+ - Bump @fluentui/react-label to v9.0.10 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
42
+ - Bump @fluentui/react-theme to v9.1.2 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
43
+ - Bump @fluentui/react-utilities to v9.2.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
44
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.18 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
45
+
46
+ ## [9.0.0-alpha.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.7)
47
+
48
+ Wed, 02 Nov 2022 11:57:52 GMT
49
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.6..@fluentui/react-field_v9.0.0-alpha.7)
50
+
51
+ ### Changes
52
+
53
+ - chore: Update Griffel to latest version ([PR #25412](https://github.com/microsoft/fluentui/pull/25412) by olfedias@microsoft.com)
54
+ - Bump @fluentui/react-checkbox to v9.0.11 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
55
+ - Bump @fluentui/react-combobox to v9.0.0-beta.14 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
56
+ - Bump @fluentui/react-context-selector to v9.1.0 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
57
+ - Bump @fluentui/react-input to v9.2.4 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
58
+ - Bump @fluentui/react-label to v9.0.9 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
59
+ - Bump @fluentui/react-progress to v9.0.0-alpha.4 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
60
+ - Bump @fluentui/react-radio to v9.0.10 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
61
+ - Bump @fluentui/react-select to v9.0.0-beta.13 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
62
+ - Bump @fluentui/react-slider to v9.0.9 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
63
+ - Bump @fluentui/react-spinbutton to v9.0.7 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
64
+ - Bump @fluentui/react-switch to v9.0.10 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
65
+ - Bump @fluentui/react-textarea to v9.1.4 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
66
+ - Bump @fluentui/react-utilities to v9.2.0 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
67
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.17 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
68
+
69
+ ## [9.0.0-alpha.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.6)
70
+
71
+ Tue, 25 Oct 2022 00:35:32 GMT
72
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.5..@fluentui/react-field_v9.0.0-alpha.6)
73
+
74
+ ### Changes
75
+
76
+ - feat: Add support for validationState to ProgressField ([PR #25253](https://github.com/microsoft/fluentui/pull/25253) by behowell@microsoft.com)
77
+ - Bump @fluentui/react-checkbox to v9.0.10 ([PR #25363](https://github.com/microsoft/fluentui/pull/25363) by beachball)
78
+ - Bump @fluentui/react-input to v9.2.3 ([PR #25363](https://github.com/microsoft/fluentui/pull/25363) by beachball)
79
+ - Bump @fluentui/react-progress to v9.0.0-alpha.3 ([PR #25363](https://github.com/microsoft/fluentui/pull/25363) by beachball)
80
+ - Bump @fluentui/react-spinbutton to v9.0.6 ([PR #25363](https://github.com/microsoft/fluentui/pull/25363) by beachball)
81
+
82
+ ## [9.0.0-alpha.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.5)
83
+
84
+ Thu, 20 Oct 2022 08:39:33 GMT
85
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.4..@fluentui/react-field_v9.0.0-alpha.5)
86
+
87
+ ### Changes
88
+
89
+ - chore: Bump peer deps to support React 18 ([PR #24972](https://github.com/microsoft/fluentui/pull/24972) by mgodbolt@microsoft.com)
90
+ - chore: Update Griffel to latest version ([PR #25212](https://github.com/microsoft/fluentui/pull/25212) by olfedias@microsoft.com)
91
+ - Bump @fluentui/react-checkbox to v9.0.9 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
92
+ - Bump @fluentui/react-combobox to v9.0.0-beta.13 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
93
+ - Bump @fluentui/react-context-selector to v9.0.5 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
94
+ - Bump @fluentui/react-input to v9.2.2 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
95
+ - Bump @fluentui/react-label to v9.0.8 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
96
+ - Bump @fluentui/react-progress to v9.0.0-alpha.2 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
97
+ - Bump @fluentui/react-radio to v9.0.9 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
98
+ - Bump @fluentui/react-select to v9.0.0-beta.12 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
99
+ - Bump @fluentui/react-slider to v9.0.8 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
100
+ - Bump @fluentui/react-spinbutton to v9.0.5 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
101
+ - Bump @fluentui/react-switch to v9.0.9 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
102
+ - Bump @fluentui/react-textarea to v9.1.3 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
103
+ - Bump @fluentui/react-theme to v9.1.1 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
104
+ - Bump @fluentui/react-utilities to v9.1.2 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
105
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.16 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
106
+
107
+ ## [9.0.0-alpha.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.4)
108
+
109
+ Thu, 13 Oct 2022 11:02:50 GMT
110
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.3..@fluentui/react-field_v9.0.0-alpha.4)
111
+
112
+ ### Changes
113
+
114
+ - Add ProgressField to @fluentui/react-field ([PR #25103](https://github.com/microsoft/fluentui/pull/25103) by ololubek@microsoft.com)
115
+ - fix: CheckboxField to set a generated ID on the input, to match the label's htmlFor ([PR #25079](https://github.com/microsoft/fluentui/pull/25079) by behowell@microsoft.com)
116
+ - chore: Update Griffel to latest version ([PR #25075](https://github.com/microsoft/fluentui/pull/25075) by olfedias@microsoft.com)
117
+ - fix: Field should have block layout, not inline ([PR #25126](https://github.com/microsoft/fluentui/pull/25126) by behowell@microsoft.com)
118
+ - Bump @fluentui/react-checkbox to v9.0.8 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
119
+ - Bump @fluentui/react-combobox to v9.0.0-beta.12 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
120
+ - Bump @fluentui/react-context-selector to v9.0.4 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
121
+ - Bump @fluentui/react-input to v9.2.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
122
+ - Bump @fluentui/react-label to v9.0.7 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
123
+ - Bump @fluentui/react-progress to v9.0.0-alpha.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
124
+ - Bump @fluentui/react-radio to v9.0.8 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
125
+ - Bump @fluentui/react-select to v9.0.0-beta.11 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
126
+ - Bump @fluentui/react-slider to v9.0.7 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
127
+ - Bump @fluentui/react-spinbutton to v9.0.4 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
128
+ - Bump @fluentui/react-switch to v9.0.8 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
129
+ - Bump @fluentui/react-textarea to v9.1.2 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
130
+ - Bump @fluentui/react-utilities to v9.1.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
131
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.15 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
132
+
133
+ ## [9.0.0-alpha.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.3)
134
+
135
+ Mon, 03 Oct 2022 22:24:37 GMT
136
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.2..@fluentui/react-field_v9.0.0-alpha.3)
137
+
138
+ ### Changes
139
+
140
+ - fix: Remove SwitchField's labelPosition prop, as it has no effect ([PR #24876](https://github.com/microsoft/fluentui/pull/24876) by behowell@microsoft.com)
141
+ - Bump @fluentui/react-checkbox to v9.0.7 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
142
+ - Bump @fluentui/react-combobox to v9.0.0-beta.11 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
143
+ - Bump @fluentui/react-input to v9.2.0 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
144
+ - Bump @fluentui/react-radio to v9.0.7 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
145
+ - Bump @fluentui/react-slider to v9.0.6 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
146
+ - Bump @fluentui/react-spinbutton to v9.0.3 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
147
+ - Bump @fluentui/react-switch to v9.0.7 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
148
+ - Bump @fluentui/react-textarea to v9.1.1 ([PR #25055](https://github.com/microsoft/fluentui/pull/25055) by beachball)
149
+
150
+ ## [9.0.0-alpha.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.2)
151
+
152
+ Tue, 20 Sep 2022 20:55:45 GMT
153
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.1..@fluentui/react-field_v9.0.0-alpha.2)
154
+
155
+ ### Changes
156
+
157
+ - Bump @fluentui/react-checkbox to v9.0.6 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
158
+ - Bump @fluentui/react-combobox to v9.0.0-beta.10 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
159
+ - Bump @fluentui/react-input to v9.1.1 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
160
+ - Bump @fluentui/react-label to v9.0.6 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
161
+ - Bump @fluentui/react-radio to v9.0.6 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
162
+ - Bump @fluentui/react-select to v9.0.0-beta.10 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
163
+ - Bump @fluentui/react-slider to v9.0.5 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
164
+ - Bump @fluentui/react-spinbutton to v9.0.2 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
165
+ - Bump @fluentui/react-switch to v9.0.6 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
166
+ - Bump @fluentui/react-textarea to v9.1.0 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
167
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.14 ([PR #24869](https://github.com/microsoft/fluentui/pull/24869) by beachball)
168
+
7
169
  ## [9.0.0-alpha.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.1)
8
170
 
9
- Thu, 15 Sep 2022 09:44:25 GMT
171
+ Thu, 15 Sep 2022 09:49:04 GMT
10
172
  [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
173
 
12
174
  ### Changes
package/dist/index.d.ts CHANGED
@@ -1,59 +1,18 @@
1
1
  /// <reference types="react" />
2
2
 
3
- import { Checkbox } from '@fluentui/react-checkbox';
4
- import type { CheckboxProps } from '@fluentui/react-checkbox';
5
- import { Combobox } from '@fluentui/react-combobox';
6
3
  import type { ComponentProps } from '@fluentui/react-utilities';
7
4
  import type { ComponentState } from '@fluentui/react-utilities';
8
- import { ForwardRefComponent } from '@fluentui/react-utilities';
9
- import { Input } from '@fluentui/react-input';
10
5
  import { Label } from '@fluentui/react-label';
11
- import { RadioGroup } from '@fluentui/react-radio';
12
6
  import * as React_2 from 'react';
13
- import { Select } from '@fluentui/react-select';
14
- import { Slider } from '@fluentui/react-slider';
15
7
  import type { Slot } from '@fluentui/react-utilities';
16
- import { SlotClassNames } from '@fluentui/react-utilities';
8
+ import type { SlotClassNames } from '@fluentui/react-utilities';
17
9
  import type { SlotRenderFunction } from '@fluentui/react-utilities';
18
10
  import type { SlotShorthandValue } from '@fluentui/react-utilities';
19
- import { SpinButton } from '@fluentui/react-spinbutton';
20
- import { Switch } from '@fluentui/react-switch';
21
- import { Textarea } from '@fluentui/react-textarea';
22
-
23
- export declare const CheckboxField: ForwardRefComponent<CheckboxFieldProps>;
24
-
25
- export declare const checkboxFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
26
-
27
- export declare type CheckboxFieldProps = Omit<FieldProps<typeof Checkbox>, 'label'> & {
28
- /**
29
- * The Checkbox's label.
30
- */
31
- label?: CheckboxProps['label'];
32
- /**
33
- * The label for the CheckboxField, which appears above or before the Checkbox, depending on the `orientation` prop.
34
- * It is recommended to only set the `label` prop, and not `fieldLabel`.
35
- */
36
- fieldLabel?: FieldProps<typeof Checkbox>['label'];
37
- };
38
-
39
- export declare const ComboboxField: ForwardRefComponent<ComboboxFieldProps>;
40
-
41
- export declare const comboboxFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
42
-
43
- export declare type ComboboxFieldProps = FieldProps<typeof Combobox>;
44
-
45
- /**
46
- * The minimum requirement for a component used by Field.
47
- *
48
- * Note: the use of VoidFunctionComponent means that component is not *required* to have a children prop,
49
- * but it is still allowed to have a children prop.
50
- */
51
- declare type FieldComponent = React_2.VoidFunctionComponent<Pick<React_2.HTMLAttributes<HTMLElement>, 'id' | 'className' | 'style' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-errormessage'>>;
52
11
 
53
12
  /**
54
13
  * Configuration parameters for a Field class, passed to useField_unstable
55
14
  */
56
- export declare type FieldConfig<T extends FieldComponent> = {
15
+ export declare type FieldConfig<T extends FieldControl> = {
57
16
  /**
58
17
  * The underlying input component that this field is wrapping.
59
18
  */
@@ -72,12 +31,26 @@ export declare type FieldConfig<T extends FieldComponent> = {
72
31
  * @default htmlFor
73
32
  */
74
33
  labelConnection?: 'htmlFor' | 'aria-labelledby';
34
+ /**
35
+ * Should the aria-invalid attribute be set when validationState="error".
36
+ *
37
+ * @default true
38
+ */
39
+ ariaInvalidOnError?: boolean;
75
40
  };
76
41
 
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'>>;
49
+
77
50
  /**
78
51
  * Field Props
79
52
  */
80
- export declare type FieldProps<T extends FieldComponent> = ComponentProps<Partial<FieldSlots<T>>, 'control'> & {
53
+ export declare type FieldProps<T extends FieldControl> = ComponentProps<Partial<FieldSlots<T>>, 'control'> & {
81
54
  /**
82
55
  * The orientation of the label relative to the field component.
83
56
  * This only affects the label, and not the validationMessage or hint (which always appear below the field component).
@@ -101,7 +74,11 @@ export declare type FieldProps<T extends FieldComponent> = ComponentProps<Partia
101
74
  * This allows Field to forward the required and size props to the label if the underlying component supports them,
102
75
  * but doesn't add them to the public API of fields that don't support them.
103
76
  */
104
- declare type FieldPropsWithOptionalComponentProps<T extends FieldComponent> = FieldProps<T> & {
77
+ declare type FieldPropsWithOptionalComponentProps<T extends FieldControl> = FieldProps<T> & {
78
+ /**
79
+ * A ref to the underlying control.
80
+ */
81
+ ref?: React_2.Ref<HTMLElement>;
105
82
  /**
106
83
  * Whether the field label should be marked as required.
107
84
  */
@@ -117,7 +94,7 @@ declare type FieldPropsWithOptionalComponentProps<T extends FieldComponent> = Fi
117
94
  /**
118
95
  * Slots added by Field
119
96
  */
120
- export declare type FieldSlots<T extends FieldComponent> = {
97
+ export declare type FieldSlots<T extends FieldControl> = {
121
98
  root: NonNullable<Slot<'div'>>;
122
99
  /**
123
100
  * The underlying component wrapped by this field.
@@ -130,7 +107,7 @@ export declare type FieldSlots<T extends FieldComponent> = {
130
107
  /**
131
108
  * A message about the validation state. The appearance of the `validationMessage` depends on `validationState`.
132
109
  */
133
- validationMessage?: Slot<'span'>;
110
+ validationMessage?: Slot<'div'>;
134
111
  /**
135
112
  * The icon associated with the `validationMessage`. If the `validationState` prop is set, this will default to an
136
113
  * icon corresponding to that state.
@@ -141,46 +118,22 @@ export declare type FieldSlots<T extends FieldComponent> = {
141
118
  /**
142
119
  * Additional hint text below the field.
143
120
  */
144
- hint?: Slot<'span'>;
121
+ hint?: Slot<'div'>;
145
122
  };
146
123
 
147
124
  /**
148
125
  * State used in rendering Field
149
126
  */
150
- export declare type FieldState<T extends FieldComponent> = ComponentState<Required<FieldSlots<T>>> & Pick<FieldProps<T>, 'orientation' | 'validationState'> & {
127
+ export declare type FieldState<T extends FieldControl> = ComponentState<Required<FieldSlots<T>>> & Pick<FieldProps<T>, 'orientation' | 'validationState'> & {
151
128
  classNames: SlotClassNames<FieldSlots<T>>;
152
129
  };
153
130
 
154
- export declare const getFieldClassNames: (name: string) => SlotClassNames<FieldSlots<FieldComponent>>;
155
-
156
- export declare const InputField: ForwardRefComponent<InputFieldProps>;
157
-
158
- export declare const inputFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
159
-
160
- export declare type InputFieldProps = FieldProps<typeof Input>;
161
-
162
- export declare const RadioGroupField: ForwardRefComponent<RadioGroupFieldProps>;
163
-
164
- export declare const radioGroupFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
165
-
166
- export declare type RadioGroupFieldProps = FieldProps<typeof RadioGroup>;
131
+ export declare const getFieldClassNames: (name: string) => SlotClassNames<FieldSlots<FieldControl>>;
167
132
 
168
133
  /**
169
134
  * Render the final JSX of Field
170
135
  */
171
- export declare const renderField_unstable: <T extends FieldComponent>(state: FieldState<T>) => JSX.Element;
172
-
173
- export declare const SelectField: ForwardRefComponent<SelectFieldProps>;
174
-
175
- export declare const selectFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
176
-
177
- export declare type SelectFieldProps = FieldProps<typeof Select>;
178
-
179
- export declare const SliderField: ForwardRefComponent<SliderFieldProps>;
180
-
181
- export declare const sliderFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
182
-
183
- export declare type SliderFieldProps = FieldProps<typeof Slider>;
136
+ export declare const renderField_unstable: <T extends FieldControl>(state: FieldState<T>) => JSX.Element;
184
137
 
185
138
  declare type SlotComponent<Type extends React_2.ComponentType | React_2.VoidFunctionComponent> = WithSlotShorthandValue<Type extends React_2.ComponentType<infer Props> ? WithSlotRenderFunction<Props extends {
186
139
  children?: unknown;
@@ -188,24 +141,6 @@ declare type SlotComponent<Type extends React_2.ComponentType | React_2.VoidFunc
188
141
  children?: never;
189
142
  }> : never>;
190
143
 
191
- export declare const SpinButtonField: ForwardRefComponent<SpinButtonFieldProps>;
192
-
193
- export declare const spinButtonFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
194
-
195
- export declare type SpinButtonFieldProps = FieldProps<typeof SpinButton>;
196
-
197
- export declare const SwitchField: ForwardRefComponent<SwitchFieldProps>;
198
-
199
- export declare const switchFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
200
-
201
- export declare type SwitchFieldProps = FieldProps<typeof Switch>;
202
-
203
- export declare const TextareaField: ForwardRefComponent<TextareaFieldProps>;
204
-
205
- export declare const textareaFieldClassNames: SlotClassNames<FieldSlots<FieldComponent>>;
206
-
207
- export declare type TextareaFieldProps = FieldProps<typeof Textarea>;
208
-
209
144
  /**
210
145
  * Create the state required to render Field.
211
146
  *
@@ -216,12 +151,12 @@ export declare type TextareaFieldProps = FieldProps<typeof Textarea>;
216
151
  * @param ref - Ref to the control slot (primary slot)
217
152
  * @param params - Configuration parameters for this Field
218
153
  */
219
- export declare const useField_unstable: <T extends FieldComponent>(props: FieldPropsWithOptionalComponentProps<T>, ref: React_2.Ref<HTMLElement>, params: FieldConfig<T>) => FieldState<T>;
154
+ export declare const useField_unstable: <T extends FieldControl>(props: FieldPropsWithOptionalComponentProps<T>, ref: React_2.Ref<HTMLElement>, params: FieldConfig<T>) => FieldState<T>;
220
155
 
221
156
  /**
222
157
  * Apply styling to the Field slots based on the state
223
158
  */
224
- export declare const useFieldStyles_unstable: <T extends FieldComponent>(state: FieldState<T>) => void;
159
+ export declare const useFieldStyles_unstable: <T extends FieldControl>(state: FieldState<T>) => void;
225
160
 
226
161
  declare type WithSlotRenderFunction<Props extends {
227
162
  children?: unknown;
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,"file":"Field.js","sourceRoot":"../src/","sources":["packages/react-components/react-field/src/Field.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './components/Field/index';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Field.types.js","sourceRoot":"../src/","sources":["components/Field/Field.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport type { ComponentProps, ComponentState, Slot, SlotClassNames } from '@fluentui/react-utilities';\nimport type { SlotComponent } from './SlotComponent.types';\n\n/**\n * The minimum requirement for a component used by Field.\n *\n * Note: the use of VoidFunctionComponent means that component is not *required* to have a children prop,\n * but it is still allowed to have a children prop.\n */\nexport type FieldComponent = React.VoidFunctionComponent<\n Pick<\n React.HTMLAttributes<HTMLElement>,\n 'id' | 'className' | 'style' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-errormessage'\n >\n>;\n\n/**\n * Slots added by Field\n */\nexport type FieldSlots<T extends FieldComponent> = {\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The underlying component wrapped by this field.\n */\n control: SlotComponent<T>;\n\n /**\n * The label associated with the field.\n */\n label?: Slot<typeof Label>;\n\n /**\n * A message about the validation state. The appearance of the `validationMessage` depends on `validationState`.\n */\n validationMessage?: Slot<'span'>;\n\n /**\n * The icon associated with the `validationMessage`. If the `validationState` prop is set, this will default to an\n * icon corresponding to that state.\n *\n * This will only be displayed if `validationMessage` is set.\n */\n validationMessageIcon?: Slot<'span'>;\n\n /**\n * Additional hint text below the field.\n */\n hint?: Slot<'span'>;\n};\n\n/**\n * Field Props\n */\nexport type FieldProps<T extends FieldComponent> = ComponentProps<Partial<FieldSlots<T>>, 'control'> & {\n /**\n * The orientation of the label relative to the field component.\n * This only affects the label, and not the validationMessage or hint (which always appear below the field component).\n *\n * @default vertical\n */\n orientation?: 'vertical' | 'horizontal';\n\n /**\n * The `validationState` affects the color of the `validationMessage`, the `validationMessageIcon`, and for some\n * field components, an `validationState=\"error\"` causes the border to become red.\n *\n * @default undefined\n */\n validationState?: 'error' | 'warning' | 'success';\n};\n\n/**\n * FieldProps plus extra optional props that are supported by useField_unstable, but not required to be part of the\n * API of every Field component.\n *\n * This allows Field to forward the required and size props to the label if the underlying component supports them,\n * but doesn't add them to the public API of fields that don't support them.\n */\nexport type FieldPropsWithOptionalComponentProps<T extends FieldComponent> = FieldProps<T> & {\n /**\n * Whether the field label should be marked as required.\n */\n required?: boolean;\n\n /**\n * Size of the field label.\n *\n * Number sizes will be ignored, but are allowed because the HTML `<input>` element has a prop `size?: number`.\n */\n size?: 'small' | 'medium' | 'large' | number;\n};\n\n/**\n * Configuration parameters for a Field class, passed to useField_unstable\n */\nexport type FieldConfig<T extends FieldComponent> = {\n /**\n * The underlying input component that this field is wrapping.\n */\n component: T;\n\n /**\n * Class names for this component, created by `getFieldClassNames`.\n */\n classNames: SlotClassNames<FieldSlots<T>>;\n\n /**\n * How the label be connected to the control.\n * * htmlFor - Set the Label's htmlFor prop to the component's ID (and generate an ID if not provided).\n * This is the preferred method for components that use the underlying <input> tag.\n * * aria-labelledby - Set the component's aria-labelledby prop to the Label's ID. Use this for components\n * that are not directly <input> elements (such as RadioGroup).\n *\n * @default htmlFor\n */\n labelConnection?: 'htmlFor' | 'aria-labelledby';\n};\n\n/**\n * State used in rendering Field\n */\nexport type FieldState<T extends FieldComponent> = ComponentState<Required<FieldSlots<T>>> &\n Pick<FieldProps<T>, 'orientation' | 'validationState'> & {\n classNames: SlotClassNames<FieldSlots<T>>;\n };\n"]}
1
+ {"version":3,"file":"Field.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-field/src/components/Field/Field.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport { Label } from '@fluentui/react-label';\nimport type { ComponentProps, ComponentState, Slot, SlotClassNames } from '@fluentui/react-utilities';\nimport type { SlotComponent } from './SlotComponent.types';\n\n/**\n * The minimum requirement for a component used by Field.\n *\n * Note: the use of VoidFunctionComponent means that component is not *required* to have a children prop,\n * but it is still allowed to have a children prop.\n */\nexport type FieldControl = React.VoidFunctionComponent<\n Pick<\n React.HTMLAttributes<HTMLElement>,\n 'id' | 'className' | 'style' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid'\n >\n>;\n\n/**\n * Slots added by Field\n */\nexport type FieldSlots<T extends FieldControl> = {\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The underlying component wrapped by this field.\n */\n control: SlotComponent<T>;\n\n /**\n * The label associated with the field.\n */\n label?: Slot<typeof Label>;\n\n /**\n * A message about the validation state. The appearance of the `validationMessage` depends on `validationState`.\n */\n validationMessage?: Slot<'div'>;\n\n /**\n * The icon associated with the `validationMessage`. If the `validationState` prop is set, this will default to an\n * icon corresponding to that state.\n *\n * This will only be displayed if `validationMessage` is set.\n */\n validationMessageIcon?: Slot<'span'>;\n\n /**\n * Additional hint text below the field.\n */\n hint?: Slot<'div'>;\n};\n\n/**\n * Field Props\n */\nexport type FieldProps<T extends FieldControl> = ComponentProps<Partial<FieldSlots<T>>, 'control'> & {\n /**\n * The orientation of the label relative to the field component.\n * This only affects the label, and not the validationMessage or hint (which always appear below the field component).\n *\n * @default vertical\n */\n orientation?: 'vertical' | 'horizontal';\n\n /**\n * The `validationState` affects the color of the `validationMessage`, the `validationMessageIcon`, and for some\n * field components, an `validationState=\"error\"` causes the border to become red.\n *\n * @default undefined\n */\n validationState?: 'error' | 'warning' | 'success';\n};\n\n/**\n * FieldProps plus extra optional props that are supported by useField_unstable, but not required to be part of the\n * API of every Field component.\n *\n * This allows Field to forward the required and size props to the label if the underlying component supports them,\n * but doesn't add them to the public API of fields that don't support them.\n */\nexport type FieldPropsWithOptionalComponentProps<T extends FieldControl> = FieldProps<T> & {\n /**\n * A ref to the underlying control.\n */\n ref?: React.Ref<HTMLElement>;\n\n /**\n * Whether the field label should be marked as required.\n */\n required?: boolean;\n\n /**\n * Size of the field label.\n *\n * Number sizes will be ignored, but are allowed because the HTML `<input>` element has a prop `size?: number`.\n */\n size?: 'small' | 'medium' | 'large' | number;\n};\n\n/**\n * Configuration parameters for a Field class, passed to useField_unstable\n */\nexport type FieldConfig<T extends FieldControl> = {\n /**\n * The underlying input component that this field is wrapping.\n */\n component: T;\n\n /**\n * Class names for this component, created by `getFieldClassNames`.\n */\n classNames: SlotClassNames<FieldSlots<T>>;\n\n /**\n * How the label be connected to the control.\n * * htmlFor - Set the Label's htmlFor prop to the component's ID (and generate an ID if not provided).\n * This is the preferred method for components that use the underlying <input> tag.\n * * aria-labelledby - Set the component's aria-labelledby prop to the Label's ID. Use this for components\n * that are not directly <input> elements (such as RadioGroup).\n *\n * @default htmlFor\n */\n labelConnection?: 'htmlFor' | 'aria-labelledby';\n\n /**\n * Should the aria-invalid attribute be set when validationState=\"error\".\n *\n * @default true\n */\n ariaInvalidOnError?: boolean;\n};\n\n/**\n * State used in rendering Field\n */\nexport type FieldState<T extends FieldControl> = ComponentState<Required<FieldSlots<T>>> &\n Pick<FieldProps<T>, 'orientation' | 'validationState'> & {\n classNames: SlotClassNames<FieldSlots<T>>;\n };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SlotComponent.types.js","sourceRoot":"../src/","sources":["components/Field/SlotComponent.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { SlotShorthandValue, SlotRenderFunction } from '@fluentui/react-utilities';\n\n//\n// TEMPORARY definition of the SlotComponent type, until it is available from react-utilities\n//\n\nexport type SlotComponent<Type extends React.ComponentType | React.VoidFunctionComponent> = WithSlotShorthandValue<\n Type extends React.ComponentType<infer Props>\n ? // If this is a VoidFunctionComponent that doesn't allow children, add { children?: never }\n WithSlotRenderFunction<Props extends { children?: unknown } ? Props : Props & { children?: never }>\n : never\n>;\n\n//\n// TEMPORARY copied versions of the non-exported helper types from react-utilities\n//\n\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\ntype WithSlotRenderFunction<Props extends { children?: unknown }> = Props & {\n children?: Props['children'] | SlotRenderFunction<Props>;\n};\n"]}
1
+ {"version":3,"file":"SlotComponent.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-field/src/components/Field/SlotComponent.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { SlotShorthandValue, SlotRenderFunction } from '@fluentui/react-utilities';\n\n//\n// TEMPORARY definition of the SlotComponent type, until it is available from react-utilities\n//\n\nexport type SlotComponent<Type extends React.ComponentType | React.VoidFunctionComponent> = WithSlotShorthandValue<\n Type extends React.ComponentType<infer Props>\n ? // If this is a VoidFunctionComponent that doesn't allow children, add { children?: never }\n WithSlotRenderFunction<Props extends { children?: unknown } ? Props : Props & { children?: never }>\n : never\n>;\n\n//\n// TEMPORARY copied versions of the non-exported helper types from react-utilities\n//\n\ntype WithSlotShorthandValue<Props extends { children?: unknown }> =\n | Props\n | Extract<SlotShorthandValue, Props['children']>;\n\ntype WithSlotRenderFunction<Props extends { children?: unknown }> = Props & {\n children?: Props['children'] | SlotRenderFunction<Props>;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Field/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './Field.types';\nexport * from './renderField';\nexport * from './useField';\nexport * from './useFieldStyles';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-field/src/components/Field/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './Field.types';\nexport * from './renderField';\nexport * from './useField';\nexport * from './useFieldStyles';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Field/renderField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAA8B,KAA3B,IAAmD;EACrF,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAA6B,KAA7B,CAArC;EAEA,oBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,KAAK,CAAC,KAAN,iBAAe,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;EAAf,CAAZ,CADlB,EAGG,KAAK,CAAC,OAAN,iBAAiB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAM,SAAS,CAAC;EAAhB,CAAd,CAHpB,EAIG,KAAK,CAAC,iBAAN,iBACC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,iBAAP,EAAwB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAxB,EACG,KAAK,CAAC,qBAAN,iBAA+B,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,qBAAP,EAA4B,EAAA,GAAK,SAAS,CAAC;EAAf,CAA5B,CADlC,EAEG,SAAS,CAAC,iBAAV,CAA4B,QAF/B,CALJ,EAUG,KAAK,CAAC,IAAN,iBAAc,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,CAVjB,CADF;AAcD,CAjBM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { FieldComponent, FieldSlots, FieldState } from './Field.types';\n\n/**\n * Render the final JSX of Field\n */\nexport const renderField_unstable = <T extends FieldComponent>(state: FieldState<T>) => {\n const { slots, slotProps } = getSlots<FieldSlots<FieldComponent>>(state as FieldState<FieldComponent>);\n\n return (\n <slots.root {...slotProps.root}>\n {slots.label && <slots.label {...slotProps.label} />}\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n {slots.control && <slots.control {...(slotProps.control as any)} />}\n {slots.validationMessage && (\n <slots.validationMessage {...slotProps.validationMessage}>\n {slots.validationMessageIcon && <slots.validationMessageIcon {...slotProps.validationMessageIcon} />}\n {slotProps.validationMessage.children}\n </slots.validationMessage>\n )}\n {slots.hint && <slots.hint {...slotProps.hint} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-field/src/components/Field/renderField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,oBAAoB,GAA4B,KAAzB,IAAiD;EACnF,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,QAAQ,CAA2B,KAA3B,CAArC;EAEA,oBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,KAAK,CAAC,KAAN,iBAAe,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;EAAf,CAAZ,CADlB,EAGG,KAAK,CAAC,OAAN,iBAAiB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAM,SAAS,CAAC;EAAhB,CAAd,CAHpB,EAIG,KAAK,CAAC,iBAAN,iBACC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,iBAAP,EAAwB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAxB,EACG,KAAK,CAAC,qBAAN,iBAA+B,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,qBAAP,EAA4B,EAAA,GAAK,SAAS,CAAC;EAAf,CAA5B,CADlC,EAEG,SAAS,CAAC,iBAAV,CAA4B,QAF/B,CALJ,EAUG,KAAK,CAAC,IAAN,iBAAc,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,CAVjB,CADF;AAcD,CAjBM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { FieldControl, FieldSlots, FieldState } from './Field.types';\n\n/**\n * Render the final JSX of Field\n */\nexport const renderField_unstable = <T extends FieldControl>(state: FieldState<T>) => {\n const { slots, slotProps } = getSlots<FieldSlots<FieldControl>>(state as FieldState<FieldControl>);\n\n return (\n <slots.root {...slotProps.root}>\n {slots.label && <slots.label {...slotProps.label} />}\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n {slots.control && <slots.control {...(slotProps.control as any)} />}\n {slots.validationMessage && (\n <slots.validationMessage {...slotProps.validationMessage}>\n {slots.validationMessageIcon && <slots.validationMessageIcon {...slotProps.validationMessageIcon} />}\n {slotProps.validationMessage.children}\n </slots.validationMessage>\n )}\n {slots.hint && <slots.hint {...slotProps.hint} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
@@ -7,17 +7,10 @@ const validationMessageIcons = {
7
7
  warning: /*#__PURE__*/React.createElement(Warning12Filled, null),
8
8
  success: /*#__PURE__*/React.createElement(CheckmarkCircle12Filled, null)
9
9
  };
10
- /**
11
- * Merge two possibly-undefined IDs for aria-describedby. If both IDs are defined, combines
12
- * them into a string separated by a space. Otherwise, returns just the defined ID (if any).
13
- */
14
-
15
- const mergeAriaDescribedBy = (a, b) => a && b ? `${a} ${b}` : a || b;
16
10
  /**
17
11
  * Partition the props used by the Field itself, from the props that are passed to the underlying field component.
18
12
  */
19
13
 
20
-
21
14
  export const getPartitionedFieldProps = props => {
22
15
  const {
23
16
  className,
@@ -58,12 +51,18 @@ export const getPartitionedFieldProps = props => {
58
51
  */
59
52
 
60
53
  export const useField_unstable = (props, ref, params) => {
54
+ var _a, _b, _c;
55
+
61
56
  const [fieldProps, controlProps] = getPartitionedFieldProps(props);
62
- const baseId = useId('field-');
63
57
  const {
64
58
  orientation = 'vertical',
65
59
  validationState
66
60
  } = fieldProps;
61
+ const {
62
+ labelConnection = 'htmlFor',
63
+ ariaInvalidOnError = true
64
+ } = params;
65
+ const baseId = useId('field-');
67
66
  const root = resolveShorthand(fieldProps.root, {
68
67
  required: true,
69
68
  defaultProps: getNativeElementProps('div', fieldProps)
@@ -72,7 +71,7 @@ export const useField_unstable = (props, ref, params) => {
72
71
  defaultProps: {
73
72
  id: baseId + '__label',
74
73
  required: controlProps.required,
75
- size: typeof controlProps.size === 'string' ? controlProps.size : undefined // htmlFor is set below
74
+ size: typeof controlProps.size === 'string' ? controlProps.size : undefined // htmlFor is handled below
76
75
 
77
76
  }
78
77
  });
@@ -91,28 +90,34 @@ export const useField_unstable = (props, ref, params) => {
91
90
  defaultProps: {
92
91
  children: validationState ? validationMessageIcons[validationState] : undefined
93
92
  }
94
- });
95
- const {
96
- labelConnection = 'htmlFor'
97
- } = params;
98
- const hasError = validationState === 'error';
93
+ }); // Hook up aria props on the control
94
+
95
+ if (label && labelConnection === 'aria-labelledby') {
96
+ (_a = controlProps['aria-labelledby']) !== null && _a !== void 0 ? _a : controlProps['aria-labelledby'] = label.id;
97
+ }
98
+
99
+ if (validationMessage || hint) {
100
+ // The control is described by the validation message, or hint, or both
101
+ // We also preserve and append any aria-describedby supplied by the user
102
+ // For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933
103
+ controlProps['aria-describedby'] = [validationMessage === null || validationMessage === void 0 ? void 0 : validationMessage.id, hint === null || hint === void 0 ? void 0 : hint.id, controlProps['aria-describedby']].filter(Boolean).join(' ');
104
+ }
105
+
106
+ if (validationState === 'error' && ariaInvalidOnError) {
107
+ (_b = controlProps['aria-invalid']) !== null && _b !== void 0 ? _b : controlProps['aria-invalid'] = true;
108
+ }
109
+
99
110
  const control = resolveShorthand(fieldProps.control, {
100
111
  required: true,
101
112
  defaultProps: {
102
113
  ref,
103
- // Add a default ID only if required for label's htmlFor prop
104
- id: label && labelConnection === 'htmlFor' ? baseId + '__control' : undefined,
105
- // Add aria-labelledby only if not using the label's htmlFor
106
- 'aria-labelledby': labelConnection !== 'htmlFor' ? label === null || label === void 0 ? void 0 : label.id : undefined,
107
- 'aria-describedby': hasError ? hint === null || hint === void 0 ? void 0 : hint.id : mergeAriaDescribedBy(validationMessage === null || validationMessage === void 0 ? void 0 : validationMessage.id, hint === null || hint === void 0 ? void 0 : hint.id),
108
- 'aria-errormessage': hasError ? validationMessage === null || validationMessage === void 0 ? void 0 : validationMessage.id : undefined,
109
- 'aria-invalid': hasError ? true : undefined,
114
+ id: baseId + '__control',
110
115
  ...controlProps
111
116
  }
112
117
  });
113
118
 
114
- if (labelConnection === 'htmlFor' && label && !label.htmlFor) {
115
- label.htmlFor = control.id;
119
+ if (label && labelConnection === 'htmlFor') {
120
+ (_c = label.htmlFor) !== null && _c !== void 0 ? _c : label.htmlFor = control.id;
116
121
  }
117
122
 
118
123
  const state = {
@@ -123,9 +128,9 @@ export const useField_unstable = (props, ref, params) => {
123
128
  root: 'div',
124
129
  control: params.component,
125
130
  label: Label,
126
- validationMessage: 'span',
131
+ validationMessage: 'div',
127
132
  validationMessageIcon: 'span',
128
- hint: 'span'
133
+ hint: 'div'
129
134
  },
130
135
  root,
131
136
  control,
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Field/useField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,uBAAT,EAAkC,mBAAlC,EAAuD,eAAvD,QAA8E,uBAA9E;AACA,SAAS,KAAT,QAAsB,uBAAtB;AACA,SAAS,qBAAT,EAAgC,gBAAhC,EAAkD,KAAlD,QAA+D,2BAA/D;AASA,MAAM,sBAAsB,GAAG;EAC7B,KAAK,eAAE,KAAA,CAAA,aAAA,CAAC,mBAAD,EAAoB,IAApB,CADsB;EAE7B,OAAO,eAAE,KAAA,CAAA,aAAA,CAAC,eAAD,EAAgB,IAAhB,CAFoB;EAG7B,OAAO,eAAE,KAAA,CAAA,aAAA,CAAC,uBAAD,EAAwB,IAAxB;AAHoB,CAA/B;AAMA;;;AAGG;;AACH,MAAM,oBAAoB,GAAG,CAAC,CAAD,EAAa,CAAb,KAA6B,CAAC,IAAI,CAAL,GAAS,GAAG,CAAC,IAAI,CAAC,EAAlB,GAAuB,CAAC,IAAI,CAAtF;AAEA;;AAEG;;;AACH,OAAO,MAAM,wBAAwB,GAA8C,KAA3C,IAA2D;EACjG,MAAM;IACJ,SADI;IAEJ,OAFI;IAGJ,IAHI;IAIJ,KAJI;IAKJ,WALI;IAMJ,IANI;I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AjB,GAAA,iBAAiB,CAAE,EAAtB,GAA2B,SAP5C;MAQZ,gBAAgB,QAAQ,GAAG,IAAH,GAAU,SARtB;MASZ,GAAG;IATS;EAFqC,CAArB,CAAhC;;EAeA,IAAI,eAAe,KAAK,SAApB,IAAiC,KAAjC,IAA0C,CAAC,KAAK,CAAC,OAArD,EAA8D;IAC5D,KAAK,CAAC,OAAN,GAAgB,OAAO,CAAC,EAAxB;EACD;;EAED,MAAM,KAAK,GAA+B;IACxC,WADwC;IAExC,eAFwC;IAGxC,UAAU,EAAE,MAAM,CAAC,UAHqB;IAIxC,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,OAAO,EAAE,MAAM,CAAC,SAFN;MAGV,KAAK,EAAE,KAHG;MAIV,iBAAiB,EAAE,MAJT;MAKV,qBAAqB,EAAE,MALb;MAMV,IAAI,EAAE;IANI,CAJ4B;IAYxC,IAZwC;IAaxC,OAbwC;IAcxC,KAdwC;IAexC,qBAfwC;IAgBxC,iBAhBwC;IAiBxC;EAjBwC,CAA1C;EAoBA,OAAO,KAAP;AACD,CAvFM","sourcesContent":["import * as React from 'react';\nimport { CheckmarkCircle12Filled, ErrorCircle12Filled, Warning12Filled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type {\n FieldComponent,\n FieldConfig,\n FieldProps,\n FieldPropsWithOptionalComponentProps,\n FieldState,\n} from './Field.types';\n\nconst validationMessageIcons = {\n error: <ErrorCircle12Filled />,\n warning: <Warning12Filled />,\n success: <CheckmarkCircle12Filled />,\n} as const;\n\n/**\n * Merge two possibly-undefined IDs for aria-describedby. If both IDs are defined, combines\n * them into a string separated by a space. Otherwise, returns just the defined ID (if any).\n */\nconst mergeAriaDescribedBy = (a?: string, b?: string) => (a && b ? `${a} ${b}` : a || b);\n\n/**\n * Partition the props used by the Field itself, from the props that are passed to the underlying field component.\n */\nexport const getPartitionedFieldProps = <Props extends FieldProps<FieldComponent>>(props: Props) => {\n const {\n className,\n control,\n hint,\n label,\n orientation,\n root,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n ...restOfProps\n } = props;\n\n const fieldProps = {\n className,\n control,\n hint,\n label,\n orientation,\n root,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n };\n\n return [fieldProps, restOfProps] as const;\n};\n\n/**\n * Create the state required to render Field.\n *\n * The returned state can be modified with hooks such as useFieldStyles_unstable,\n * before being passed to renderField_unstable.\n *\n * @param props - Props passed to this field\n * @param ref - Ref to the control slot (primary slot)\n * @param params - Configuration parameters for this Field\n */\nexport const useField_unstable = <T extends FieldComponent>(\n props: FieldPropsWithOptionalComponentProps<T>,\n ref: React.Ref<HTMLElement>,\n params: FieldConfig<T>,\n): FieldState<T> => {\n const [fieldProps, controlProps] = getPartitionedFieldProps(props);\n\n const baseId = useId('field-');\n\n const { orientation = 'vertical', validationState } = fieldProps;\n\n const root = resolveShorthand(fieldProps.root, {\n required: true,\n defaultProps: getNativeElementProps('div', fieldProps),\n });\n\n const label = resolveShorthand(fieldProps.label, {\n defaultProps: {\n id: baseId + '__label',\n required: controlProps.required,\n size: typeof controlProps.size === 'string' ? controlProps.size : undefined,\n // htmlFor is set below\n },\n });\n\n const validationMessage = resolveShorthand(fieldProps.validationMessage, {\n defaultProps: {\n id: baseId + '__validationMessage',\n },\n });\n\n const hint = resolveShorthand(fieldProps.hint, {\n defaultProps: {\n id: baseId + '__hint',\n },\n });\n\n const validationMessageIcon = resolveShorthand(fieldProps.validationMessageIcon, {\n required: !!validationState,\n defaultProps: {\n children: validationState ? validationMessageIcons[validationState] : undefined,\n },\n });\n\n const { labelConnection = 'htmlFor' } = params;\n const hasError = validationState === 'error';\n\n const control = resolveShorthand(fieldProps.control, {\n required: true,\n defaultProps: {\n ref,\n // Add a default ID only if required for label's htmlFor prop\n id: label && labelConnection === 'htmlFor' ? baseId + '__control' : undefined,\n // Add aria-labelledby only if not using the label's htmlFor\n 'aria-labelledby': labelConnection !== 'htmlFor' ? label?.id : undefined,\n 'aria-describedby': hasError ? hint?.id : mergeAriaDescribedBy(validationMessage?.id, hint?.id),\n 'aria-errormessage': hasError ? validationMessage?.id : undefined,\n 'aria-invalid': hasError ? true : undefined,\n ...controlProps,\n },\n });\n\n if (labelConnection === 'htmlFor' && label && !label.htmlFor) {\n label.htmlFor = control.id;\n }\n\n const state: FieldState<FieldComponent> = {\n orientation,\n validationState,\n classNames: params.classNames,\n components: {\n root: 'div',\n control: params.component,\n label: Label,\n validationMessage: 'span',\n validationMessageIcon: 'span',\n hint: 'span',\n },\n root,\n control,\n label,\n validationMessageIcon,\n validationMessage,\n hint,\n };\n\n return state as FieldState<T>;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-field/src/components/Field/useField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,uBAAT,EAAkC,mBAAlC,EAAuD,eAAvD,QAA8E,uBAA9E;AACA,SAAS,KAAT,QAAsB,uBAAtB;AACA,SAAS,qBAAT,EAAgC,gBAAhC,EAAkD,KAAlD,QAA+D,2BAA/D;AAGA,MAAM,sBAAsB,GAAG;EAC7B,KAAK,eAAE,KAAA,CAAA,aAAA,CAAC,mBAAD,EAAoB,IAApB,CADsB;EAE7B,OAAO,eAAE,KAAA,CAAA,aAAA,CAAC,eAAD,EAAgB,IAAhB,CAFoB;EAG7B,OAAO,eAAE,KAAA,CAAA,aAAA,CAAC,uBAAD,EAAwB,IAAxB;AAHoB,CAA/B;AAMA;;AAEG;;AACH,OAAO,MAAM,wBAAwB,GAAI,KAAD,IAA8D;EACpG,MAAM;IACJ,SADI;IAEJ,OAFI;IAGJ,IAHI;IAIJ,KAJI;IAKJ,WALI;IAMJ,IANI;IAOJ,KAPI;IAQJ,iBARI;IASJ,qBATI;IAUJ,eAVI;IAWJ,GAAG;EAXC,IAYF,KAZJ;EAcA,MAAM,UAAU,GAAG;IACjB,S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IADyC;IAEnD,YAAY,EAAE;MACZ,GADY;MAEZ,EAAE,EAAE,MAAM,GAAG,WAFD;MAGZ,GAAG;IAHS;EAFqC,CAArB,CAAhC;;EASA,IAAI,KAAK,IAAI,eAAe,KAAK,SAAjC,EAA4C;IAC1C,CAAA,EAAA,GAAA,KAAK,CAAC,OAAN,MAAa,IAAb,IAAa,EAAA,KAAA,KAAA,CAAb,GAAa,EAAb,GAAA,KAAK,CAAC,OAAN,GAAkB,OAAO,CAAC,EAA1B;EACD;;EAED,MAAM,KAAK,GAA6B;IACtC,WADsC;IAEtC,eAFsC;IAGtC,UAAU,EAAE,MAAM,CAAC,UAHmB;IAItC,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,OAAO,EAAE,MAAM,CAAC,SAFN;MAGV,KAAK,EAAE,KAHG;MAIV,iBAAiB,EAAE,KAJT;MAKV,qBAAqB,EAAE,MALb;MAMV,IAAI,EAAE;IANI,CAJ0B;IAYtC,IAZsC;IAatC,OAbsC;IActC,KAdsC;IAetC,qBAfsC;IAgBtC,iBAhBsC;IAiBtC;EAjBsC,CAAxC;EAoBA,OAAO,KAAP;AACD,CAhGM","sourcesContent":["import * as React from 'react';\nimport { CheckmarkCircle12Filled, ErrorCircle12Filled, Warning12Filled } from '@fluentui/react-icons';\nimport { Label } from '@fluentui/react-label';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport type { FieldConfig, FieldControl, FieldPropsWithOptionalComponentProps, FieldState } from './Field.types';\n\nconst validationMessageIcons = {\n error: <ErrorCircle12Filled />,\n warning: <Warning12Filled />,\n success: <CheckmarkCircle12Filled />,\n} as const;\n\n/**\n * Partition the props used by the Field itself, from the props that are passed to the underlying field component.\n */\nexport const getPartitionedFieldProps = (props: FieldPropsWithOptionalComponentProps<FieldControl>) => {\n const {\n className,\n control,\n hint,\n label,\n orientation,\n root,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n ...restOfProps\n } = props;\n\n const fieldProps = {\n className,\n control,\n hint,\n label,\n orientation,\n root,\n style,\n validationMessage,\n validationMessageIcon,\n validationState,\n };\n\n return [fieldProps, restOfProps] as const;\n};\n\n/**\n * Create the state required to render Field.\n *\n * The returned state can be modified with hooks such as useFieldStyles_unstable,\n * before being passed to renderField_unstable.\n *\n * @param props - Props passed to this field\n * @param ref - Ref to the control slot (primary slot)\n * @param params - Configuration parameters for this Field\n */\nexport const useField_unstable = <T extends FieldControl>(\n props: FieldPropsWithOptionalComponentProps<T>,\n ref: React.Ref<HTMLElement>,\n params: FieldConfig<T>,\n): FieldState<T> => {\n const [fieldProps, controlProps] = getPartitionedFieldProps(props);\n const { orientation = 'vertical', validationState } = fieldProps;\n const { labelConnection = 'htmlFor', ariaInvalidOnError = true } = params;\n\n const baseId = useId('field-');\n\n const root = resolveShorthand(fieldProps.root, {\n required: true,\n defaultProps: getNativeElementProps('div', fieldProps),\n });\n\n const label = resolveShorthand(fieldProps.label, {\n defaultProps: {\n id: baseId + '__label',\n required: controlProps.required,\n size: typeof controlProps.size === 'string' ? controlProps.size : undefined,\n // htmlFor is handled below\n },\n });\n\n const validationMessage = resolveShorthand(fieldProps.validationMessage, {\n defaultProps: {\n id: baseId + '__validationMessage',\n },\n });\n\n const hint = resolveShorthand(fieldProps.hint, {\n defaultProps: {\n id: baseId + '__hint',\n },\n });\n\n const validationMessageIcon = resolveShorthand(fieldProps.validationMessageIcon, {\n required: !!validationState,\n defaultProps: {\n children: validationState ? validationMessageIcons[validationState] : undefined,\n },\n });\n\n // Hook up aria props on the control\n if (label && labelConnection === 'aria-labelledby') {\n controlProps['aria-labelledby'] ??= label.id;\n }\n\n if (validationMessage || hint) {\n // The control is described by the validation message, or hint, or both\n // We also preserve and append any aria-describedby supplied by the user\n // For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933\n controlProps['aria-describedby'] = [validationMessage?.id, hint?.id, controlProps['aria-describedby']]\n .filter(Boolean)\n .join(' ');\n }\n\n if (validationState === 'error' && ariaInvalidOnError) {\n controlProps['aria-invalid'] ??= true;\n }\n\n const control = resolveShorthand(fieldProps.control, {\n required: true,\n defaultProps: {\n ref,\n id: baseId + '__control',\n ...controlProps,\n },\n });\n\n if (label && labelConnection === 'htmlFor') {\n label.htmlFor ??= control.id;\n }\n\n const state: FieldState<FieldControl> = {\n orientation,\n validationState,\n classNames: params.classNames,\n components: {\n root: 'div',\n control: params.component,\n label: Label,\n validationMessage: 'div',\n validationMessageIcon: 'span',\n hint: 'div',\n },\n root,\n control,\n label,\n validationMessageIcon,\n validationMessage,\n hint,\n };\n\n return state as FieldState<T>;\n};\n"],"sourceRoot":"../src/"}