@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
@@ -1,5 +1,5 @@
1
- import { __styles, mergeClasses } from '@griffel/react';
2
1
  import { tokens, typographyStyles } from '@fluentui/react-theme';
2
+ import { __styles, mergeClasses } from '@griffel/react';
3
3
  export const getFieldClassNames = name => ({
4
4
  root: `fui-${name}`,
5
5
  control: `fui-${name}__control`,
@@ -14,7 +14,7 @@ export const getFieldClassNames = name => ({
14
14
 
15
15
  const useRootStyles = /*#__PURE__*/__styles({
16
16
  "base": {
17
- "mc9l5x": "fwk3njj",
17
+ "mc9l5x": "f13qh94s",
18
18
  "Bxotwcr": "f14np9u9",
19
19
  "B7hvi0a": "f1m2n5bn"
20
20
  },
@@ -26,7 +26,7 @@ const useRootStyles = /*#__PURE__*/__styles({
26
26
  "Br312pm": "fd46tj4"
27
27
  }
28
28
  }, {
29
- "d": [".fwk3njj{display:inline-grid;}", ".f14np9u9{grid-auto-flow:row;}", ".f1m2n5bn{justify-items:start;}", ".fai812u{grid-template-rows:auto auto auto auto;}", ".fckz59x{grid-template-columns:1fr 2fr;}", ".fd46tj4{grid-column-start:2;}"]
29
+ "d": [".f13qh94s{display:grid;}", ".f14np9u9{grid-auto-flow:row;}", ".f1m2n5bn{justify-items:start;}", ".fai812u{grid-template-rows:auto auto auto auto;}", ".fckz59x{grid-template-columns:1fr 2fr;}", ".fd46tj4{grid-column-start:2;}"]
30
30
  });
31
31
 
32
32
  const useLabelStyles = /*#__PURE__*/__styles({
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Field/useFieldStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,QAAyC,gBAAzC;AAGA,SAAS,MAAT,EAAiB,gBAAjB,Q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EAEjC,mBAAmB,CAAC,IAFa,EAGjC,UAAU,IAAI,UAAU,CAAC,YAHQ,EAIjC,KAAK,CAAC,IAAN,CAAW,SAJsB,CAAnC;EAMD;AACF,CA5DM","sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport type { FieldComponent, FieldProps, FieldSlots, FieldState } from './Field.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\n\nexport const getFieldClassNames = (name: string): SlotClassNames<FieldSlots<FieldComponent>> => ({\n root: `fui-${name}`,\n control: `fui-${name}__control`,\n label: `fui-${name}__label`,\n validationMessage: `fui-${name}__validationMessage`,\n validationMessageIcon: `fui-${name}__validationMessageIcon`,\n hint: `fui-${name}__hint`,\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n base: {\n display: 'inline-grid',\n gridAutoFlow: 'row',\n justifyItems: 'start',\n },\n\n horizontal: {\n gridTemplateRows: 'auto auto auto auto',\n gridTemplateColumns: '1fr 2fr',\n },\n\n secondColumn: {\n gridColumnStart: '2',\n },\n});\n\nconst useLabelStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n marginBottom: tokens.spacingVerticalXXS,\n },\n\n horizontal: {\n gridRowStart: '1',\n gridRowEnd: '-1',\n marginRight: tokens.spacingHorizontalM,\n alignSelf: 'start',\n justifySelf: 'stretch',\n },\n});\n\nconst useSecondaryTextStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.caption1,\n },\n\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n});\n\nconst useValidationMessageIconStyles = makeStyles({\n base: {\n fontSize: '12px',\n lineHeight: '12px',\n verticalAlign: 'middle',\n marginRight: tokens.spacingHorizontalXS,\n },\n\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n warning: {\n color: tokens.colorPaletteDarkOrangeForeground1,\n },\n success: {\n color: tokens.colorPaletteGreenForeground1,\n },\n});\n\n/**\n * Apply styling to the Field slots based on the state\n */\nexport const useFieldStyles_unstable = <T extends FieldComponent>(state: FieldState<T>) => {\n const classNames = state.classNames;\n const validationState: FieldProps<FieldComponent>['validationState'] = state.validationState;\n const horizontal = state.orientation === 'horizontal';\n\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n classNames.root,\n rootStyles.base,\n horizontal && rootStyles.horizontal,\n state.root.className,\n );\n\n if (state.control) {\n state.control.className = mergeClasses(\n classNames.control,\n horizontal && rootStyles.secondColumn,\n state.control.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n classNames.label,\n labelStyles.base,\n horizontal && labelStyles.horizontal,\n state.label.className,\n );\n }\n\n const validationMessageIconStyles = useValidationMessageIconStyles();\n if (state.validationMessageIcon) {\n state.validationMessageIcon.className = mergeClasses(\n classNames.validationMessageIcon,\n validationMessageIconStyles.base,\n !!validationState && validationMessageIconStyles[validationState],\n state.validationMessageIcon.className,\n );\n }\n\n const secondaryTextStyles = useSecondaryTextStyles();\n if (state.validationMessage) {\n state.validationMessage.className = mergeClasses(\n classNames.validationMessage,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n validationState === 'error' && secondaryTextStyles.error,\n state.validationMessage.className,\n );\n }\n\n if (state.hint) {\n state.hint.className = mergeClasses(\n classNames.hint,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n state.hint.className,\n );\n }\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-field/src/components/Field/useFieldStyles.ts"],"names":[],"mappings":"AAAA,SAAS,MAAT,EAAiB,gBAAjB,QAAyC,uBAAzC;AAEA,mBAAqB,YAArB,QAAyC,gBAAzC;AAGA,OAAO,MAAM,kBAAkB,GAAI,IAAD,KAA6D;EAC7F,IAAI,EAAE,OAAO,IAAI,EAD4E;EAE7F,OAAO,EAAE,OAAO,IAAI,WAFyE;EAG7F,KAA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typographyStyles } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport type { FieldControl, FieldProps, FieldSlots, FieldState } from './Field.types';\n\nexport const getFieldClassNames = (name: string): SlotClassNames<FieldSlots<FieldControl>> => ({\n root: `fui-${name}`,\n control: `fui-${name}__control`,\n label: `fui-${name}__label`,\n validationMessage: `fui-${name}__validationMessage`,\n validationMessageIcon: `fui-${name}__validationMessageIcon`,\n hint: `fui-${name}__hint`,\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n base: {\n display: 'grid',\n gridAutoFlow: 'row',\n justifyItems: 'start',\n },\n\n horizontal: {\n gridTemplateRows: 'auto auto auto auto',\n gridTemplateColumns: '1fr 2fr',\n },\n\n secondColumn: {\n gridColumnStart: '2',\n },\n});\n\nconst useLabelStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n marginBottom: tokens.spacingVerticalXXS,\n },\n\n horizontal: {\n gridRowStart: '1',\n gridRowEnd: '-1',\n marginRight: tokens.spacingHorizontalM,\n alignSelf: 'start',\n justifySelf: 'stretch',\n },\n});\n\nconst useSecondaryTextStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.caption1,\n },\n\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n});\n\nconst useValidationMessageIconStyles = makeStyles({\n base: {\n fontSize: '12px',\n lineHeight: '12px',\n verticalAlign: 'middle',\n marginRight: tokens.spacingHorizontalXS,\n },\n\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n warning: {\n color: tokens.colorPaletteDarkOrangeForeground1,\n },\n success: {\n color: tokens.colorPaletteGreenForeground1,\n },\n});\n\n/**\n * Apply styling to the Field slots based on the state\n */\nexport const useFieldStyles_unstable = <T extends FieldControl>(state: FieldState<T>) => {\n const classNames = state.classNames;\n const validationState: FieldProps<FieldControl>['validationState'] = state.validationState;\n const horizontal = state.orientation === 'horizontal';\n\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n classNames.root,\n rootStyles.base,\n horizontal && rootStyles.horizontal,\n state.root.className,\n );\n\n if (state.control) {\n state.control.className = mergeClasses(\n classNames.control,\n horizontal && rootStyles.secondColumn,\n state.control.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n classNames.label,\n labelStyles.base,\n horizontal && labelStyles.horizontal,\n state.label.className,\n );\n }\n\n const validationMessageIconStyles = useValidationMessageIconStyles();\n if (state.validationMessageIcon) {\n state.validationMessageIcon.className = mergeClasses(\n classNames.validationMessageIcon,\n validationMessageIconStyles.base,\n !!validationState && validationMessageIconStyles[validationState],\n state.validationMessageIcon.className,\n );\n }\n\n const secondaryTextStyles = useSecondaryTextStyles();\n if (state.validationMessage) {\n state.validationMessage.className = mergeClasses(\n classNames.validationMessage,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n validationState === 'error' && secondaryTextStyles.error,\n state.validationMessage.className,\n );\n }\n\n if (state.hint) {\n state.hint.className = mergeClasses(\n classNames.hint,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n state.hint.className,\n );\n }\n};\n"],"sourceRoot":"../src/"}
package/lib/index.js CHANGED
@@ -1,11 +1,2 @@
1
1
  export { getFieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';
2
- export { CheckboxField, checkboxFieldClassNames } from './CheckboxField';
3
- export { ComboboxField, comboboxFieldClassNames } from './ComboboxField';
4
- export { InputField, inputFieldClassNames } from './InputField';
5
- export { RadioGroupField, radioGroupFieldClassNames } from './RadioGroupField';
6
- export { SelectField, selectFieldClassNames } from './SelectField';
7
- export { SliderField, sliderFieldClassNames } from './SliderField';
8
- export { SpinButtonField, spinButtonFieldClassNames } from './SpinButtonField';
9
- export { SwitchField, switchFieldClassNames } from './SwitchField';
10
- export { TextareaField, textareaFieldClassNames } from './TextareaField';
11
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG/G,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGnE,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { getFieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';\nexport type { FieldProps, FieldSlots, FieldState, FieldConfig } from './Field';\n\nexport { CheckboxField, checkboxFieldClassNames } from './CheckboxField';\nexport type { CheckboxFieldProps } from './CheckboxField';\n\nexport { ComboboxField, comboboxFieldClassNames } from './ComboboxField';\nexport type { ComboboxFieldProps } from './ComboboxField';\n\nexport { InputField, inputFieldClassNames } from './InputField';\nexport type { InputFieldProps } from './InputField';\n\nexport { RadioGroupField, radioGroupFieldClassNames } from './RadioGroupField';\nexport type { RadioGroupFieldProps } from './RadioGroupField';\n\nexport { SelectField, selectFieldClassNames } from './SelectField';\nexport type { SelectFieldProps } from './SelectField';\n\nexport { SliderField, sliderFieldClassNames } from './SliderField';\nexport type { SliderFieldProps } from './SliderField';\n\nexport { SpinButtonField, spinButtonFieldClassNames } from './SpinButtonField';\nexport type { SpinButtonFieldProps } from './SpinButtonField';\n\nexport { SwitchField, switchFieldClassNames } from './SwitchField';\nexport type { SwitchFieldProps } from './SwitchField';\n\nexport { TextareaField, textareaFieldClassNames } from './TextareaField';\nexport type { TextareaFieldProps } from './TextareaField';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-field/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { getFieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';\nexport type { FieldConfig, FieldControl, FieldProps, FieldSlots, FieldState } from './Field';\n"]}
@@ -0,0 +1,6 @@
1
+ define(["require", "exports", "tslib", "./components/Field/index"], function (require, exports, tslib_1, index_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(index_1, exports);
5
+ });
6
+ //# sourceMappingURL=Field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Field.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-field/src/Field.ts"],"names":[],"mappings":";;;IAAA,uCAAyC","sourcesContent":["export * from './components/Field/index';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=Field.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Field.types.js","sourceRoot":"","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"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=SlotComponent.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlotComponent.types.js","sourceRoot":"","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"]}
@@ -0,0 +1,9 @@
1
+ define(["require", "exports", "tslib", "./Field.types", "./renderField", "./useField", "./useFieldStyles"], function (require, exports, tslib_1, Field_types_1, renderField_1, useField_1, useFieldStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(Field_types_1, exports);
5
+ tslib_1.__exportStar(renderField_1, exports);
6
+ tslib_1.__exportStar(useField_1, exports);
7
+ tslib_1.__exportStar(useFieldStyles_1, exports);
8
+ });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-field/src/components/Field/index.ts"],"names":[],"mappings":";;;IAAA,6CAA8B;IAC9B,6CAA8B;IAC9B,0CAA2B;IAC3B,gDAAiC","sourcesContent":["export * from './Field.types';\nexport * from './renderField';\nexport * from './useField';\nexport * from './useFieldStyles';\n"]}
@@ -0,0 +1,20 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_utilities_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderField_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of Field
7
+ */
8
+ var renderField_unstable = function (state) {
9
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
+ return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
11
+ slots.label && React.createElement(slots.label, tslib_1.__assign({}, slotProps.label)),
12
+ slots.control && React.createElement(slots.control, tslib_1.__assign({}, slotProps.control)),
13
+ slots.validationMessage && (React.createElement(slots.validationMessage, tslib_1.__assign({}, slotProps.validationMessage),
14
+ slots.validationMessageIcon && React.createElement(slots.validationMessageIcon, tslib_1.__assign({}, slotProps.validationMessageIcon)),
15
+ slotProps.validationMessage.children)),
16
+ slots.hint && React.createElement(slots.hint, tslib_1.__assign({}, slotProps.hint))));
17
+ };
18
+ exports.renderField_unstable = renderField_unstable;
19
+ });
20
+ //# sourceMappingURL=renderField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderField.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-field/src/components/Field/renderField.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,oBAAoB,GAAG,UAAyB,KAAoB;QACzE,IAAA,KAAuB,0BAAQ,CAA2B,KAAiC,CAAC,EAA1F,KAAK,WAAA,EAAE,SAAS,eAA0E,CAAC;QAEnG,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC3B,KAAK,CAAC,KAAK,IAAI,oBAAC,KAAK,CAAC,KAAK,uBAAK,SAAS,CAAC,KAAK,EAAI;YAEnD,KAAK,CAAC,OAAO,IAAI,oBAAC,KAAK,CAAC,OAAO,uBAAM,SAAS,CAAC,OAAe,EAAI;YAClE,KAAK,CAAC,iBAAiB,IAAI,CAC1B,oBAAC,KAAK,CAAC,iBAAiB,uBAAK,SAAS,CAAC,iBAAiB;gBACrD,KAAK,CAAC,qBAAqB,IAAI,oBAAC,KAAK,CAAC,qBAAqB,uBAAK,SAAS,CAAC,qBAAqB,EAAI;gBACnG,SAAS,CAAC,iBAAiB,CAAC,QAAQ,CACb,CAC3B;YACA,KAAK,CAAC,IAAI,IAAI,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CACtC,CACd,CAAC;IACJ,CAAC,CAAC;IAjBW,QAAA,oBAAoB,wBAiB/B","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"]}
@@ -0,0 +1,119 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-icons", "@fluentui/react-label", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_icons_1, react_label_1, react_utilities_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useField_unstable = exports.getPartitionedFieldProps = void 0;
5
+ var validationMessageIcons = {
6
+ error: React.createElement(react_icons_1.ErrorCircle12Filled, null),
7
+ warning: React.createElement(react_icons_1.Warning12Filled, null),
8
+ success: React.createElement(react_icons_1.CheckmarkCircle12Filled, null),
9
+ };
10
+ /**
11
+ * Partition the props used by the Field itself, from the props that are passed to the underlying field component.
12
+ */
13
+ var getPartitionedFieldProps = function (props) {
14
+ var className = props.className, control = props.control, hint = props.hint, label = props.label, orientation = props.orientation, root = props.root, style = props.style, validationMessage = props.validationMessage, validationMessageIcon = props.validationMessageIcon, validationState = props.validationState, restOfProps = tslib_1.__rest(props, ["className", "control", "hint", "label", "orientation", "root", "style", "validationMessage", "validationMessageIcon", "validationState"]);
15
+ var fieldProps = {
16
+ className: className,
17
+ control: control,
18
+ hint: hint,
19
+ label: label,
20
+ orientation: orientation,
21
+ root: root,
22
+ style: style,
23
+ validationMessage: validationMessage,
24
+ validationMessageIcon: validationMessageIcon,
25
+ validationState: validationState,
26
+ };
27
+ return [fieldProps, restOfProps];
28
+ };
29
+ exports.getPartitionedFieldProps = getPartitionedFieldProps;
30
+ /**
31
+ * Create the state required to render Field.
32
+ *
33
+ * The returned state can be modified with hooks such as useFieldStyles_unstable,
34
+ * before being passed to renderField_unstable.
35
+ *
36
+ * @param props - Props passed to this field
37
+ * @param ref - Ref to the control slot (primary slot)
38
+ * @param params - Configuration parameters for this Field
39
+ */
40
+ var useField_unstable = function (props, ref, params) {
41
+ var _a, _b, _c;
42
+ var _d = exports.getPartitionedFieldProps(props), fieldProps = _d[0], controlProps = _d[1];
43
+ var _e = fieldProps.orientation, orientation = _e === void 0 ? 'vertical' : _e, validationState = fieldProps.validationState;
44
+ var _f = params.labelConnection, labelConnection = _f === void 0 ? 'htmlFor' : _f, _g = params.ariaInvalidOnError, ariaInvalidOnError = _g === void 0 ? true : _g;
45
+ var baseId = react_utilities_1.useId('field-');
46
+ var root = react_utilities_1.resolveShorthand(fieldProps.root, {
47
+ required: true,
48
+ defaultProps: react_utilities_1.getNativeElementProps('div', fieldProps),
49
+ });
50
+ var label = react_utilities_1.resolveShorthand(fieldProps.label, {
51
+ defaultProps: {
52
+ id: baseId + '__label',
53
+ required: controlProps.required,
54
+ size: typeof controlProps.size === 'string' ? controlProps.size : undefined,
55
+ // htmlFor is handled below
56
+ },
57
+ });
58
+ var validationMessage = react_utilities_1.resolveShorthand(fieldProps.validationMessage, {
59
+ defaultProps: {
60
+ id: baseId + '__validationMessage',
61
+ },
62
+ });
63
+ var hint = react_utilities_1.resolveShorthand(fieldProps.hint, {
64
+ defaultProps: {
65
+ id: baseId + '__hint',
66
+ },
67
+ });
68
+ var validationMessageIcon = react_utilities_1.resolveShorthand(fieldProps.validationMessageIcon, {
69
+ required: !!validationState,
70
+ defaultProps: {
71
+ children: validationState ? validationMessageIcons[validationState] : undefined,
72
+ },
73
+ });
74
+ // Hook up aria props on the control
75
+ if (label && labelConnection === 'aria-labelledby') {
76
+ (_a = controlProps['aria-labelledby']) !== null && _a !== void 0 ? _a : (controlProps['aria-labelledby'] = label.id);
77
+ }
78
+ if (validationMessage || hint) {
79
+ // The control is described by the validation message, or hint, or both
80
+ // We also preserve and append any aria-describedby supplied by the user
81
+ // For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933
82
+ controlProps['aria-describedby'] = [validationMessage === null || validationMessage === void 0 ? void 0 : validationMessage.id, hint === null || hint === void 0 ? void 0 : hint.id, controlProps['aria-describedby']]
83
+ .filter(Boolean)
84
+ .join(' ');
85
+ }
86
+ if (validationState === 'error' && ariaInvalidOnError) {
87
+ (_b = controlProps['aria-invalid']) !== null && _b !== void 0 ? _b : (controlProps['aria-invalid'] = true);
88
+ }
89
+ var control = react_utilities_1.resolveShorthand(fieldProps.control, {
90
+ required: true,
91
+ defaultProps: tslib_1.__assign({ ref: ref, id: baseId + '__control' }, controlProps),
92
+ });
93
+ if (label && labelConnection === 'htmlFor') {
94
+ (_c = label.htmlFor) !== null && _c !== void 0 ? _c : (label.htmlFor = control.id);
95
+ }
96
+ var state = {
97
+ orientation: orientation,
98
+ validationState: validationState,
99
+ classNames: params.classNames,
100
+ components: {
101
+ root: 'div',
102
+ control: params.component,
103
+ label: react_label_1.Label,
104
+ validationMessage: 'div',
105
+ validationMessageIcon: 'span',
106
+ hint: 'div',
107
+ },
108
+ root: root,
109
+ control: control,
110
+ label: label,
111
+ validationMessageIcon: validationMessageIcon,
112
+ validationMessage: validationMessage,
113
+ hint: hint,
114
+ };
115
+ return state;
116
+ };
117
+ exports.useField_unstable = useField_unstable;
118
+ });
119
+ //# sourceMappingURL=useField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useField.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-field/src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A;YACP,KAAK,OAAA;YACL,qBAAqB,uBAAA;YACrB,iBAAiB,mBAAA;YACjB,IAAI,MAAA;SACL,CAAC;QAEF,OAAO,KAAsB,CAAC;IAChC,CAAC,CAAC;IAhGW,QAAA,iBAAiB,qBAgG5B","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"]}
@@ -0,0 +1,97 @@
1
+ define(["require", "exports", "tslib", "@fluentui/react-theme", "@griffel/react"], function (require, exports, tslib_1, react_theme_1, react_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useFieldStyles_unstable = exports.getFieldClassNames = void 0;
5
+ var getFieldClassNames = function (name) { return ({
6
+ root: "fui-" + name,
7
+ control: "fui-" + name + "__control",
8
+ label: "fui-" + name + "__label",
9
+ validationMessage: "fui-" + name + "__validationMessage",
10
+ validationMessageIcon: "fui-" + name + "__validationMessageIcon",
11
+ hint: "fui-" + name + "__hint",
12
+ }); };
13
+ exports.getFieldClassNames = getFieldClassNames;
14
+ /**
15
+ * Styles for the root slot
16
+ */
17
+ var useRootStyles = react_1.makeStyles({
18
+ base: {
19
+ display: 'grid',
20
+ gridAutoFlow: 'row',
21
+ justifyItems: 'start',
22
+ },
23
+ horizontal: {
24
+ gridTemplateRows: 'auto auto auto auto',
25
+ gridTemplateColumns: '1fr 2fr',
26
+ },
27
+ secondColumn: {
28
+ gridColumnStart: '2',
29
+ },
30
+ });
31
+ var useLabelStyles = react_1.makeStyles({
32
+ base: {
33
+ marginTop: react_theme_1.tokens.spacingVerticalXXS,
34
+ marginBottom: react_theme_1.tokens.spacingVerticalXXS,
35
+ },
36
+ horizontal: {
37
+ gridRowStart: '1',
38
+ gridRowEnd: '-1',
39
+ marginRight: react_theme_1.tokens.spacingHorizontalM,
40
+ alignSelf: 'start',
41
+ justifySelf: 'stretch',
42
+ },
43
+ });
44
+ var useSecondaryTextStyles = react_1.makeStyles({
45
+ base: tslib_1.__assign({ marginTop: react_theme_1.tokens.spacingVerticalXXS, color: react_theme_1.tokens.colorNeutralForeground3 }, react_theme_1.typographyStyles.caption1),
46
+ error: {
47
+ color: react_theme_1.tokens.colorPaletteRedForeground1,
48
+ },
49
+ });
50
+ var useValidationMessageIconStyles = react_1.makeStyles({
51
+ base: {
52
+ fontSize: '12px',
53
+ lineHeight: '12px',
54
+ verticalAlign: 'middle',
55
+ marginRight: react_theme_1.tokens.spacingHorizontalXS,
56
+ },
57
+ error: {
58
+ color: react_theme_1.tokens.colorPaletteRedForeground1,
59
+ },
60
+ warning: {
61
+ color: react_theme_1.tokens.colorPaletteDarkOrangeForeground1,
62
+ },
63
+ success: {
64
+ color: react_theme_1.tokens.colorPaletteGreenForeground1,
65
+ },
66
+ });
67
+ /**
68
+ * Apply styling to the Field slots based on the state
69
+ */
70
+ var useFieldStyles_unstable = function (state) {
71
+ var classNames = state.classNames;
72
+ var validationState = state.validationState;
73
+ var horizontal = state.orientation === 'horizontal';
74
+ var rootStyles = useRootStyles();
75
+ state.root.className = react_1.mergeClasses(classNames.root, rootStyles.base, horizontal && rootStyles.horizontal, state.root.className);
76
+ if (state.control) {
77
+ state.control.className = react_1.mergeClasses(classNames.control, horizontal && rootStyles.secondColumn, state.control.className);
78
+ }
79
+ var labelStyles = useLabelStyles();
80
+ if (state.label) {
81
+ state.label.className = react_1.mergeClasses(classNames.label, labelStyles.base, horizontal && labelStyles.horizontal, state.label.className);
82
+ }
83
+ var validationMessageIconStyles = useValidationMessageIconStyles();
84
+ if (state.validationMessageIcon) {
85
+ state.validationMessageIcon.className = react_1.mergeClasses(classNames.validationMessageIcon, validationMessageIconStyles.base, !!validationState && validationMessageIconStyles[validationState], state.validationMessageIcon.className);
86
+ }
87
+ var secondaryTextStyles = useSecondaryTextStyles();
88
+ if (state.validationMessage) {
89
+ state.validationMessage.className = react_1.mergeClasses(classNames.validationMessage, secondaryTextStyles.base, horizontal && rootStyles.secondColumn, validationState === 'error' && secondaryTextStyles.error, state.validationMessage.className);
90
+ }
91
+ if (state.hint) {
92
+ state.hint.className = react_1.mergeClasses(classNames.hint, secondaryTextStyles.base, horizontal && rootStyles.secondColumn, state.hint.className);
93
+ }
94
+ };
95
+ exports.useFieldStyles_unstable = useFieldStyles_unstable;
96
+ });
97
+ //# sourceMappingURL=useFieldStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-field/src/components/Field/useFieldStyles.ts"],"names":[],"mappings":";;;;IAKO,IAAM,kBAAkB,GAAG,UAAC,IAAY,IAA+C,OAAA,CAAC;QAC7F,IAAI,EAAE,SAAO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,EAAE;YAC/B,KAAK,CAAC,qBAAqB,CAAC,SAAS,GAAG,oBAAY,CAClD,UAAU,CAAC,qBAAqB,EAChC,2BAA2B,CAAC,IAAI,EAChC,CAAC,CAAC,eAAe,IAAI,2BAA2B,CAAC,eAAe,CAAC,EACjE,KAAK,CAAC,qBAAqB,CAAC,SAAS,CACtC,CAAC;SACH;QAED,IAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,iBAAiB,CAAC,SAAS,GAAG,oBAAY,CAC9C,UAAU,CAAC,iBAAiB,EAC5B,mBAAmB,CAAC,IAAI,EACxB,UAAU,IAAI,UAAU,CAAC,YAAY,EACrC,eAAe,KAAK,OAAO,IAAI,mBAAmB,CAAC,KAAK,EACxD,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAClC,CAAC;SACH;QAED,IAAI,KAAK,CAAC,IAAI,EAAE;YACd,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,oBAAY,CACjC,UAAU,CAAC,IAAI,EACf,mBAAmB,CAAC,IAAI,EACxB,UAAU,IAAI,UAAU,CAAC,YAAY,EACrC,KAAK,CAAC,IAAI,CAAC,SAAS,CACrB,CAAC;SACH;IACH,CAAC,CAAC;IA5DW,QAAA,uBAAuB,2BA4DlC","sourcesContent":["import { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses } from '@griffel/react';\nimport type { FieldControl, FieldProps, FieldSlots, FieldState } from './Field.types';\n\nexport const getFieldClassNames = (name: string): SlotClassNames<FieldSlots<FieldControl>> => ({\n root: `fui-${name}`,\n control: `fui-${name}__control`,\n label: `fui-${name}__label`,\n validationMessage: `fui-${name}__validationMessage`,\n validationMessageIcon: `fui-${name}__validationMessageIcon`,\n hint: `fui-${name}__hint`,\n});\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n base: {\n display: 'grid',\n gridAutoFlow: 'row',\n justifyItems: 'start',\n },\n\n horizontal: {\n gridTemplateRows: 'auto auto auto auto',\n gridTemplateColumns: '1fr 2fr',\n },\n\n secondColumn: {\n gridColumnStart: '2',\n },\n});\n\nconst useLabelStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n marginBottom: tokens.spacingVerticalXXS,\n },\n\n horizontal: {\n gridRowStart: '1',\n gridRowEnd: '-1',\n marginRight: tokens.spacingHorizontalM,\n alignSelf: 'start',\n justifySelf: 'stretch',\n },\n});\n\nconst useSecondaryTextStyles = makeStyles({\n base: {\n marginTop: tokens.spacingVerticalXXS,\n color: tokens.colorNeutralForeground3,\n ...typographyStyles.caption1,\n },\n\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n});\n\nconst useValidationMessageIconStyles = makeStyles({\n base: {\n fontSize: '12px',\n lineHeight: '12px',\n verticalAlign: 'middle',\n marginRight: tokens.spacingHorizontalXS,\n },\n\n error: {\n color: tokens.colorPaletteRedForeground1,\n },\n warning: {\n color: tokens.colorPaletteDarkOrangeForeground1,\n },\n success: {\n color: tokens.colorPaletteGreenForeground1,\n },\n});\n\n/**\n * Apply styling to the Field slots based on the state\n */\nexport const useFieldStyles_unstable = <T extends FieldControl>(state: FieldState<T>) => {\n const classNames = state.classNames;\n const validationState: FieldProps<FieldControl>['validationState'] = state.validationState;\n const horizontal = state.orientation === 'horizontal';\n\n const rootStyles = useRootStyles();\n state.root.className = mergeClasses(\n classNames.root,\n rootStyles.base,\n horizontal && rootStyles.horizontal,\n state.root.className,\n );\n\n if (state.control) {\n state.control.className = mergeClasses(\n classNames.control,\n horizontal && rootStyles.secondColumn,\n state.control.className,\n );\n }\n\n const labelStyles = useLabelStyles();\n if (state.label) {\n state.label.className = mergeClasses(\n classNames.label,\n labelStyles.base,\n horizontal && labelStyles.horizontal,\n state.label.className,\n );\n }\n\n const validationMessageIconStyles = useValidationMessageIconStyles();\n if (state.validationMessageIcon) {\n state.validationMessageIcon.className = mergeClasses(\n classNames.validationMessageIcon,\n validationMessageIconStyles.base,\n !!validationState && validationMessageIconStyles[validationState],\n state.validationMessageIcon.className,\n );\n }\n\n const secondaryTextStyles = useSecondaryTextStyles();\n if (state.validationMessage) {\n state.validationMessage.className = mergeClasses(\n classNames.validationMessage,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n validationState === 'error' && secondaryTextStyles.error,\n state.validationMessage.className,\n );\n }\n\n if (state.hint) {\n state.hint.className = mergeClasses(\n classNames.hint,\n secondaryTextStyles.base,\n horizontal && rootStyles.secondColumn,\n state.hint.className,\n );\n }\n};\n"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "./Field"], function (require, exports, Field_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useField_unstable = exports.useFieldStyles_unstable = exports.renderField_unstable = exports.getFieldClassNames = void 0;
5
+ Object.defineProperty(exports, "getFieldClassNames", { enumerable: true, get: function () { return Field_1.getFieldClassNames; } });
6
+ Object.defineProperty(exports, "renderField_unstable", { enumerable: true, get: function () { return Field_1.renderField_unstable; } });
7
+ Object.defineProperty(exports, "useFieldStyles_unstable", { enumerable: true, get: function () { return Field_1.useFieldStyles_unstable; } });
8
+ Object.defineProperty(exports, "useField_unstable", { enumerable: true, get: function () { return Field_1.useField_unstable; } });
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/react-components/react-field/src/index.ts"],"names":[],"mappings":";;;;IAAS,2GAAA,kBAAkB,OAAA;IAAE,6GAAA,oBAAoB,OAAA;IAAE,gHAAA,uBAAuB,OAAA;IAAE,0GAAA,iBAAiB,OAAA","sourcesContent":["export { getFieldClassNames, renderField_unstable, useFieldStyles_unstable, useField_unstable } from './Field';\nexport type { FieldConfig, FieldControl, FieldProps, FieldSlots, FieldState } from './Field';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["Field.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Field/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-field/src/Field.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,0BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Field/index';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Field/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Field.types';\nexport * from './renderField';\nexport * from './useField';\nexport * from './useFieldStyles';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["packages/react-components/react-field/src/components/Field/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Field.types';\nexport * from './renderField';\nexport * from './useField';\nexport * from './useFieldStyles';\n"],"sourceRoot":"../src/"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Field/renderField.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,oBAAoB,GAA8B,KAA3B,IAAmD;EACrF,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAAqC,KAArC,CAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,KAAK,CAAC,KAAN,IAAe,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;EAAf,CAAZ,CADlB,EAGG,KAAK,CAAC,OAAN,IAAiB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAM,SAAS,CAAC;EAAhB,CAAd,CAHpB,EAIG,KAAK,CAAC,iBAAN,IACC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,iBAAP,EAAwB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAxB,EACG,KAAK,CAAC,qBAAN,IAA+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,IAAc,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,CAVjB,CADF;AAcD,CAjBM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","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,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,oBAAoB,GAA4B,KAAzB,IAAiD;EACnF,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAAmC,KAAnC,CAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACG,KAAK,CAAC,KAAN,IAAe,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;EAAf,CAAZ,CADlB,EAGG,KAAK,CAAC,OAAN,IAAiB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAM,SAAS,CAAC;EAAhB,CAAd,CAHpB,EAIG,KAAK,CAAC,iBAAN,IACC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,iBAAP,EAAwB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAxB,EACG,KAAK,CAAC,qBAAN,IAA+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,IAAc,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,CAVjB,CADF;AAcD,CAjBM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","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/"}
@@ -18,17 +18,10 @@ const validationMessageIcons = {
18
18
  warning: /*#__PURE__*/React.createElement(react_icons_1.Warning12Filled, null),
19
19
  success: /*#__PURE__*/React.createElement(react_icons_1.CheckmarkCircle12Filled, null)
20
20
  };
21
- /**
22
- * Merge two possibly-undefined IDs for aria-describedby. If both IDs are defined, combines
23
- * them into a string separated by a space. Otherwise, returns just the defined ID (if any).
24
- */
25
-
26
- const mergeAriaDescribedBy = (a, b) => a && b ? `${a} ${b}` : a || b;
27
21
  /**
28
22
  * Partition the props used by the Field itself, from the props that are passed to the underlying field component.
29
23
  */
30
24
 
31
-
32
25
  const getPartitionedFieldProps = props => {
33
26
  const {
34
27
  className,
@@ -71,12 +64,18 @@ exports.getPartitionedFieldProps = getPartitionedFieldProps;
71
64
  */
72
65
 
73
66
  const useField_unstable = (props, ref, params) => {
67
+ var _a, _b, _c;
68
+
74
69
  const [fieldProps, controlProps] = exports.getPartitionedFieldProps(props);
75
- const baseId = react_utilities_1.useId('field-');
76
70
  const {
77
71
  orientation = 'vertical',
78
72
  validationState
79
73
  } = fieldProps;
74
+ const {
75
+ labelConnection = 'htmlFor',
76
+ ariaInvalidOnError = true
77
+ } = params;
78
+ const baseId = react_utilities_1.useId('field-');
80
79
  const root = react_utilities_1.resolveShorthand(fieldProps.root, {
81
80
  required: true,
82
81
  defaultProps: react_utilities_1.getNativeElementProps('div', fieldProps)
@@ -85,7 +84,7 @@ const useField_unstable = (props, ref, params) => {
85
84
  defaultProps: {
86
85
  id: baseId + '__label',
87
86
  required: controlProps.required,
88
- size: typeof controlProps.size === 'string' ? controlProps.size : undefined // htmlFor is set below
87
+ size: typeof controlProps.size === 'string' ? controlProps.size : undefined // htmlFor is handled below
89
88
 
90
89
  }
91
90
  });
@@ -104,28 +103,34 @@ const useField_unstable = (props, ref, params) => {
104
103
  defaultProps: {
105
104
  children: validationState ? validationMessageIcons[validationState] : undefined
106
105
  }
107
- });
108
- const {
109
- labelConnection = 'htmlFor'
110
- } = params;
111
- const hasError = validationState === 'error';
106
+ }); // Hook up aria props on the control
107
+
108
+ if (label && labelConnection === 'aria-labelledby') {
109
+ (_a = controlProps['aria-labelledby']) !== null && _a !== void 0 ? _a : controlProps['aria-labelledby'] = label.id;
110
+ }
111
+
112
+ if (validationMessage || hint) {
113
+ // The control is described by the validation message, or hint, or both
114
+ // We also preserve and append any aria-describedby supplied by the user
115
+ // For reference: https://github.com/microsoft/fluentui/pull/25580#discussion_r1017259933
116
+ 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(' ');
117
+ }
118
+
119
+ if (validationState === 'error' && ariaInvalidOnError) {
120
+ (_b = controlProps['aria-invalid']) !== null && _b !== void 0 ? _b : controlProps['aria-invalid'] = true;
121
+ }
122
+
112
123
  const control = react_utilities_1.resolveShorthand(fieldProps.control, {
113
124
  required: true,
114
125
  defaultProps: {
115
126
  ref,
116
- // Add a default ID only if required for label's htmlFor prop
117
- id: label && labelConnection === 'htmlFor' ? baseId + '__control' : undefined,
118
- // Add aria-labelledby only if not using the label's htmlFor
119
- 'aria-labelledby': labelConnection !== 'htmlFor' ? label === null || label === void 0 ? void 0 : label.id : undefined,
120
- '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),
121
- 'aria-errormessage': hasError ? validationMessage === null || validationMessage === void 0 ? void 0 : validationMessage.id : undefined,
122
- 'aria-invalid': hasError ? true : undefined,
127
+ id: baseId + '__control',
123
128
  ...controlProps
124
129
  }
125
130
  });
126
131
 
127
- if (labelConnection === 'htmlFor' && label && !label.htmlFor) {
128
- label.htmlFor = control.id;
132
+ if (label && labelConnection === 'htmlFor') {
133
+ (_c = label.htmlFor) !== null && _c !== void 0 ? _c : label.htmlFor = control.id;
129
134
  }
130
135
 
131
136
  const state = {
@@ -136,9 +141,9 @@ const useField_unstable = (props, ref, params) => {
136
141
  root: 'div',
137
142
  control: params.component,
138
143
  label: react_label_1.Label,
139
- validationMessage: 'span',
144
+ validationMessage: 'div',
140
145
  validationMessageIcon: 'span',
141
- hint: 'span'
146
+ hint: 'div'
142
147
  },
143
148
  root,
144
149
  control,