@instructure/ui-form-field 8.13.1-snapshot.9 → 8.14.0

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 (68) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/es/FormField/index.js +3 -2
  3. package/es/FormField/props.js +0 -15
  4. package/es/FormFieldGroup/index.js +14 -10
  5. package/es/FormFieldGroup/props.js +0 -19
  6. package/es/FormFieldLabel/index.js +13 -7
  7. package/es/FormFieldLabel/props.js +2 -2
  8. package/es/FormFieldLayout/index.js +15 -10
  9. package/es/FormFieldLayout/props.js +5 -24
  10. package/es/FormFieldLayout/styles.js +1 -1
  11. package/es/FormFieldMessage/index.js +12 -8
  12. package/es/FormFieldMessages/index.js +11 -6
  13. package/es/FormFieldMessages/props.js +0 -6
  14. package/lib/FormField/index.js +3 -2
  15. package/lib/FormField/props.js +0 -15
  16. package/lib/FormFieldGroup/index.js +14 -10
  17. package/lib/FormFieldGroup/props.js +0 -19
  18. package/lib/FormFieldLabel/index.js +13 -7
  19. package/lib/FormFieldLabel/props.js +2 -2
  20. package/lib/FormFieldLayout/index.js +15 -10
  21. package/lib/FormFieldLayout/props.js +5 -24
  22. package/lib/FormFieldLayout/styles.js +1 -1
  23. package/lib/FormFieldMessage/index.js +12 -8
  24. package/lib/FormFieldMessages/index.js +11 -6
  25. package/lib/FormFieldMessages/props.js +0 -6
  26. package/package.json +15 -16
  27. package/src/FormField/index.tsx +3 -3
  28. package/src/FormField/props.ts +17 -14
  29. package/src/FormFieldGroup/index.tsx +6 -10
  30. package/src/FormFieldGroup/props.ts +24 -17
  31. package/src/FormFieldLabel/index.tsx +4 -6
  32. package/src/FormFieldLabel/props.ts +3 -3
  33. package/src/FormFieldLayout/index.tsx +10 -16
  34. package/src/FormFieldLayout/props.ts +30 -20
  35. package/src/FormFieldLayout/styles.ts +1 -2
  36. package/src/FormFieldMessage/index.tsx +5 -8
  37. package/src/FormFieldMessages/index.tsx +4 -6
  38. package/src/FormFieldMessages/props.ts +6 -6
  39. package/src/index.ts +1 -1
  40. package/tsconfig.build.json +19 -2
  41. package/tsconfig.build.tsbuildinfo +1 -0
  42. package/types/FormField/index.d.ts +4 -30
  43. package/types/FormField/index.d.ts.map +1 -1
  44. package/types/FormField/props.d.ts +17 -2
  45. package/types/FormField/props.d.ts.map +1 -1
  46. package/types/FormFieldGroup/index.d.ts +4 -4
  47. package/types/FormFieldGroup/index.d.ts.map +1 -1
  48. package/types/FormFieldGroup/props.d.ts +18 -2
  49. package/types/FormFieldGroup/props.d.ts.map +1 -1
  50. package/types/FormFieldLabel/index.d.ts +4 -3
  51. package/types/FormFieldLabel/index.d.ts.map +1 -1
  52. package/types/FormFieldLabel/props.d.ts +1 -1
  53. package/types/FormFieldLabel/props.d.ts.map +1 -1
  54. package/types/FormFieldLayout/index.d.ts +7 -32
  55. package/types/FormFieldLayout/index.d.ts.map +1 -1
  56. package/types/FormFieldLayout/props.d.ts +21 -2
  57. package/types/FormFieldLayout/props.d.ts.map +1 -1
  58. package/types/FormFieldLayout/styles.d.ts +1 -1
  59. package/types/FormFieldLayout/styles.d.ts.map +1 -1
  60. package/types/FormFieldMessage/index.d.ts +2 -2
  61. package/types/FormFieldMessage/index.d.ts.map +1 -1
  62. package/types/FormFieldMessages/index.d.ts +2 -1
  63. package/types/FormFieldMessages/index.d.ts.map +1 -1
  64. package/types/FormFieldMessages/props.d.ts +6 -0
  65. package/types/FormFieldMessages/props.d.ts.map +1 -1
  66. package/types/index.d.ts +1 -1
  67. package/types/index.d.ts.map +1 -1
  68. package/LICENSE.md +0 -27
@@ -45,10 +45,12 @@ var _dec, _class, _class2, _temp;
45
45
  ---
46
46
  parent: FormField
47
47
  ---
48
+ @tsProps
48
49
  **/
49
50
  let FormFieldLayout = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_class = (_temp = _class2 = class FormFieldLayout extends _react.Component {
50
51
  constructor(props) {
51
52
  super(props);
53
+ this._messagesId = void 0;
52
54
  this.ref = null;
53
55
 
54
56
  this.handleRef = el => {
@@ -61,7 +63,7 @@ let FormFieldLayout = (_dec = (0, _emotion.withStyle)(_styles.default, null), _d
61
63
  };
62
64
 
63
65
  this.handleInputContainerRef = node => {
64
- if (this.props.inputContainerRef) {
66
+ if (typeof this.props.inputContainerRef === 'function') {
65
67
  this.props.inputContainerRef(node);
66
68
  }
67
69
  };
@@ -72,11 +74,15 @@ let FormFieldLayout = (_dec = (0, _emotion.withStyle)(_styles.default, null), _d
72
74
  }
73
75
 
74
76
  componentDidMount() {
75
- this.props.makeStyles();
77
+ var _this$props$makeStyle, _this$props;
78
+
79
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
76
80
  }
77
81
 
78
- componentDidUpdate(prevProps, prevState, snapshot) {
79
- this.props.makeStyles();
82
+ componentDidUpdate() {
83
+ var _this$props$makeStyle2, _this$props2;
84
+
85
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
80
86
  }
81
87
 
82
88
  get hasVisibleLabel() {
@@ -134,10 +140,10 @@ let FormFieldLayout = (_dec = (0, _emotion.withStyle)(_styles.default, null), _d
134
140
 
135
141
  render() {
136
142
  const ElementType = this.elementType;
137
- const _this$props = this.props,
138
- makeStyles = _this$props.makeStyles,
139
- styles = _this$props.styles,
140
- props = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
143
+ const _this$props3 = this.props,
144
+ makeStyles = _this$props3.makeStyles,
145
+ styles = _this$props3.styles,
146
+ props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
141
147
  const width = props.width,
142
148
  layout = props.layout,
143
149
  children = props.children;
@@ -146,7 +152,7 @@ let FormFieldLayout = (_dec = (0, _emotion.withStyle)(_styles.default, null), _d
146
152
  style: {
147
153
  width
148
154
  },
149
- "aria-describedby": this.hasMessages ? this._messagesId : null,
155
+ "aria-describedby": this.hasMessages ? this._messagesId : void 0,
150
156
  ref: this.handleRef
151
157
  }), this.elementType === 'fieldset' && this.renderLegend(), (0, _emotion.jsx)(_Grid.Grid, Object.assign({
152
158
  rowSpacing: "small",
@@ -159,7 +165,6 @@ let FormFieldLayout = (_dec = (0, _emotion.withStyle)(_styles.default, null), _d
159
165
  }
160
166
 
161
167
  }, _class2.displayName = "FormFieldLayout", _class2.componentId = 'FormFieldLayout', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
162
- children: null,
163
168
  inline: false,
164
169
  layout: 'stacked',
165
170
  as: 'label',
@@ -36,41 +36,22 @@ var _FormPropTypes = require("../FormPropTypes");
36
36
  */
37
37
  const propTypes = {
38
38
  label: _propTypes.default.node.isRequired,
39
-
40
- /**
41
- * the id of the input (to link it to its label for a11y)
42
- */
43
39
  id: _propTypes.default.string,
44
-
45
- /**
46
- * the element type to render as
47
- */
48
40
  as: _propTypes.default.elementType,
49
-
50
- /**
51
- * object with shape: `{
52
- * text: PropTypes.node,
53
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
54
- * }`
55
- */
56
41
  messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message),
57
-
58
- /**
59
- * id for the form field messages
60
- */
61
42
  messagesId: _propTypes.default.string,
62
43
  children: _propTypes.default.node,
63
44
  inline: _propTypes.default.bool,
64
45
  layout: _propTypes.default.oneOf(['stacked', 'inline']),
65
46
  labelAlign: _propTypes.default.oneOf(['start', 'end']),
47
+ vAlign: _propTypes.default.oneOf(['top', 'middle', 'bottom']),
66
48
  width: _propTypes.default.string,
67
49
  inputContainerRef: _propTypes.default.func,
68
-
69
- /**
70
- * provides a reference to the underlying html root element
71
- */
72
50
  elementRef: _propTypes.default.func
73
51
  };
74
52
  exports.propTypes = propTypes;
75
- const allowedProps = ['label', 'id', 'as', 'messages', 'messagesId', 'children', 'inline', 'layout', 'labelAlign', 'width', 'inputContainerRef', 'elementRef'];
53
+ const allowedProps = ['label', 'id', 'as', 'messages', 'messagesId', 'children', 'inline', 'layout', 'labelAlign', 'width', 'inputContainerRef', 'elementRef' // added vAlign because FormField and FormFieldGroup passes it, but not adding
54
+ // it to allowedProps to prevent it from getting passed through accidentally
55
+ //'vAlign'
56
+ ];
76
57
  exports.allowedProps = allowedProps;
@@ -39,7 +39,7 @@ exports.default = void 0;
39
39
  * @param {Object} state the state of the component, the style is applied to
40
40
  * @return {Object} The final style object, which will be used in the component
41
41
  */
42
- const generateStyle = (componentTheme, props) => {
42
+ const generateStyle = (_componentTheme, props) => {
43
43
  const inline = props.inline;
44
44
  return {
45
45
  formFieldLayout: {
@@ -25,6 +25,7 @@ var _dec, _class, _class2, _temp;
25
25
  ---
26
26
  parent: FormField
27
27
  ---
28
+ @tsProps
28
29
 
29
30
  This is a helper component that is used by most of the custom form
30
31
  components. In most cases it shouldn't be used directly.
@@ -47,17 +48,21 @@ let FormFieldMessage = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.d
47
48
  }
48
49
 
49
50
  componentDidMount() {
50
- this.props.makeStyles();
51
+ var _this$props$makeStyle, _this$props;
52
+
53
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
51
54
  }
52
55
 
53
- componentDidUpdate(prevProps, prevState, snapshot) {
54
- this.props.makeStyles();
56
+ componentDidUpdate() {
57
+ var _this$props$makeStyle2, _this$props2;
58
+
59
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
55
60
  }
56
61
 
57
62
  render() {
58
- const _this$props = this.props,
59
- children = _this$props.children,
60
- styles = _this$props.styles;
63
+ const _this$props3 = this.props,
64
+ children = _this$props3.children,
65
+ styles = _this$props3.styles;
61
66
  return this.props.variant !== 'screenreader-only' ? (0, _emotion.jsx)("span", {
62
67
  css: styles === null || styles === void 0 ? void 0 : styles.formFieldMessage,
63
68
  ref: this.handleRef
@@ -67,8 +72,7 @@ let FormFieldMessage = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.d
67
72
  }
68
73
 
69
74
  }, _class2.displayName = "FormFieldMessage", _class2.componentId = 'FormFieldMessage', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
70
- variant: 'hint',
71
- children: null
75
+ variant: 'hint'
72
76
  }, _temp)) || _class);
73
77
  exports.FormFieldMessage = FormFieldMessage;
74
78
  var _default = FormFieldMessage;
@@ -27,6 +27,7 @@ var _dec, _class, _class2, _temp;
27
27
  ---
28
28
  parent: FormField
29
29
  ---
30
+ @tsProps
30
31
 
31
32
  A FormFieldMessages component
32
33
 
@@ -52,17 +53,21 @@ let FormFieldMessages = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.
52
53
  }
53
54
 
54
55
  componentDidMount() {
55
- this.props.makeStyles();
56
+ var _this$props$makeStyle, _this$props;
57
+
58
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
56
59
  }
57
60
 
58
- componentDidUpdate(prevProps, prevState, snapshot) {
59
- this.props.makeStyles();
61
+ componentDidUpdate() {
62
+ var _this$props$makeStyle2, _this$props2;
63
+
64
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
60
65
  }
61
66
 
62
67
  render() {
63
- const _this$props = this.props,
64
- messages = _this$props.messages,
65
- styles = _this$props.styles;
68
+ const _this$props3 = this.props,
69
+ messages = _this$props3.messages,
70
+ styles = _this$props3.styles;
66
71
  return messages && messages.length > 0 ? (0, _emotion.jsx)("span", Object.assign({
67
72
  css: styles === null || styles === void 0 ? void 0 : styles.formFieldMessages
68
73
  }, (0, _omitProps.omitProps)(this.props, FormFieldMessages.allowedProps), {
@@ -35,12 +35,6 @@ var _FormPropTypes = require("../FormPropTypes");
35
35
  * SOFTWARE.
36
36
  */
37
37
  const propTypes = {
38
- /**
39
- * object with shape: `{
40
- * text: PropTypes.node,
41
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
42
- * }`
43
- */
44
38
  messages: _propTypes.default.arrayOf(_FormPropTypes.FormPropTypes.message)
45
39
  };
46
40
  exports.propTypes = propTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-form-field",
3
- "version": "8.13.1-snapshot.9+f32ba918e",
3
+ "version": "8.14.0",
4
4
  "description": "Form layout components.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "type": "commonjs",
@@ -24,22 +24,22 @@
24
24
  },
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@instructure/ui-babel-preset": "8.13.1-snapshot.9+f32ba918e",
28
- "@instructure/ui-test-utils": "8.13.1-snapshot.9+f32ba918e",
29
- "@instructure/ui-themes": "8.13.1-snapshot.9+f32ba918e"
27
+ "@instructure/ui-babel-preset": "8.14.0",
28
+ "@instructure/ui-test-utils": "8.14.0",
29
+ "@instructure/ui-themes": "8.14.0"
30
30
  },
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.13.10",
33
- "@instructure/console": "8.13.1-snapshot.9+f32ba918e",
34
- "@instructure/emotion": "8.13.1-snapshot.9+f32ba918e",
35
- "@instructure/shared-types": "8.13.1-snapshot.9+f32ba918e",
36
- "@instructure/ui-a11y-content": "8.13.1-snapshot.9+f32ba918e",
37
- "@instructure/ui-a11y-utils": "8.13.1-snapshot.9+f32ba918e",
38
- "@instructure/ui-grid": "8.13.1-snapshot.9+f32ba918e",
39
- "@instructure/ui-icons": "8.13.1-snapshot.9+f32ba918e",
40
- "@instructure/ui-react-utils": "8.13.1-snapshot.9+f32ba918e",
41
- "@instructure/ui-utils": "8.13.1-snapshot.9+f32ba918e",
42
- "@instructure/uid": "8.13.1-snapshot.9+f32ba918e",
33
+ "@instructure/console": "8.14.0",
34
+ "@instructure/emotion": "8.14.0",
35
+ "@instructure/shared-types": "8.14.0",
36
+ "@instructure/ui-a11y-content": "8.14.0",
37
+ "@instructure/ui-a11y-utils": "8.14.0",
38
+ "@instructure/ui-grid": "8.14.0",
39
+ "@instructure/ui-icons": "8.14.0",
40
+ "@instructure/ui-react-utils": "8.14.0",
41
+ "@instructure/ui-utils": "8.14.0",
42
+ "@instructure/uid": "8.14.0",
43
43
  "prop-types": "^15"
44
44
  },
45
45
  "peerDependencies": {
@@ -47,6 +47,5 @@
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
50
- },
51
- "gitHead": "f32ba918e4d3ce76c6ee95c856584d00a9d80958"
50
+ }
52
51
  }
@@ -35,6 +35,7 @@ import type { FormFieldProps } from './props'
35
35
  ---
36
36
  category: components
37
37
  ---
38
+ @tsProps
38
39
  **/
39
40
  class FormField extends Component<FormFieldProps> {
40
41
  static readonly componentId = 'FormField'
@@ -45,8 +46,7 @@ class FormField extends Component<FormFieldProps> {
45
46
  inline: false,
46
47
  layout: 'stacked',
47
48
  labelAlign: 'end',
48
- vAlign: 'middle',
49
- children: null
49
+ vAlign: 'middle'
50
50
  }
51
51
 
52
52
  ref: Element | null = null
@@ -66,7 +66,7 @@ class FormField extends Component<FormFieldProps> {
66
66
  <FormFieldLayout
67
67
  {...omitProps(this.props, FormField.allowedProps)}
68
68
  {...pickProps(this.props, FormFieldLayout.allowedProps)}
69
- // @ts-expect-error ts-migrate(2322) FIXME: Remove this comment to see the full error message
69
+ label={this.props.label}
70
70
  vAlign={this.props.vAlign}
71
71
  as="label"
72
72
  htmlFor={this.props.id}
@@ -35,8 +35,20 @@ import type { FormMessage } from '../FormPropTypes'
35
35
 
36
36
  type FormFieldOwnProps = {
37
37
  label: React.ReactNode
38
+ /**
39
+ * the id of the input (to link it to its label for a11y)
40
+ */
38
41
  id: string
42
+ /**
43
+ * Array of objects with shape: `{
44
+ * text: React.ReactNode,
45
+ * type: One of: ['error', 'hint', 'success', 'screenreader-only']
46
+ * }`
47
+ */
39
48
  messages?: FormMessage[]
49
+ /**
50
+ * id for the form field messages
51
+ */
40
52
  messagesId?: string
41
53
  children?: React.ReactNode
42
54
  inline?: boolean
@@ -44,7 +56,10 @@ type FormFieldOwnProps = {
44
56
  labelAlign?: 'start' | 'end'
45
57
  vAlign?: 'top' | 'middle' | 'bottom'
46
58
  width?: string
47
- inputContainerRef?: (...args: any[]) => any
59
+ inputContainerRef?: (element: HTMLSpanElement | null) => void
60
+ /**
61
+ * provides a reference to the underlying html root element
62
+ */
48
63
  elementRef?: (element: Element | null) => void
49
64
  }
50
65
 
@@ -56,16 +71,7 @@ type FormFieldProps = FormFieldOwnProps & OtherHTMLAttributes<FormFieldOwnProps>
56
71
 
57
72
  const propTypes: PropValidators<PropKeys> = {
58
73
  label: PropTypes.node.isRequired,
59
- /**
60
- * the id of the input (to link it to its label for a11y)
61
- */
62
74
  id: PropTypes.string.isRequired,
63
- /**
64
- * object with shape: `{
65
- * text: PropTypes.node,
66
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
67
- * }`
68
- */
69
75
  messages: PropTypes.arrayOf(FormPropTypes.message),
70
76
  messagesId: PropTypes.string,
71
77
  children: PropTypes.node,
@@ -75,9 +81,6 @@ const propTypes: PropValidators<PropKeys> = {
75
81
  vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
76
82
  width: PropTypes.string,
77
83
  inputContainerRef: PropTypes.func,
78
- /**
79
- * provides a reference to the underlying html root element
80
- */
81
84
  elementRef: PropTypes.func
82
85
  }
83
86
 
@@ -96,5 +99,5 @@ const allowedProps: AllowedPropKeys = [
96
99
  'elementRef'
97
100
  ]
98
101
 
99
- export type { FormFieldProps }
102
+ export type { FormFieldOwnProps, FormFieldProps }
100
103
  export { propTypes, allowedProps }
@@ -41,6 +41,7 @@ import type { FormFieldGroupProps, FormFieldGroupStyleProps } from './props'
41
41
  ---
42
42
  category: components
43
43
  ---
44
+ @tsProps
44
45
  **/
45
46
  @withStyle(generateStyle, generateComponentTheme)
46
47
  class FormFieldGroup extends Component<FormFieldGroupProps> {
@@ -49,7 +50,6 @@ class FormFieldGroup extends Component<FormFieldGroupProps> {
49
50
  static propTypes = propTypes
50
51
  static allowedProps = allowedProps
51
52
  static defaultProps = {
52
- children: null,
53
53
  as: 'fieldset',
54
54
  disabled: false,
55
55
  rowSpacing: 'medium',
@@ -70,14 +70,11 @@ class FormFieldGroup extends Component<FormFieldGroupProps> {
70
70
  }
71
71
 
72
72
  componentDidMount() {
73
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
74
- this.props.makeStyles(this.makeStylesVariables)
73
+ this.props.makeStyles?.(this.makeStylesVariables)
75
74
  }
76
75
 
77
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
78
- componentDidUpdate(prevProps, prevState, snapshot) {
79
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
80
- this.props.makeStyles(this.makeStylesVariables)
76
+ componentDidUpdate() {
77
+ this.props.makeStyles?.(this.makeStylesVariables)
81
78
  }
82
79
 
83
80
  get makeStylesVariables(): FormFieldGroupStyleProps {
@@ -143,12 +140,11 @@ class FormFieldGroup extends Component<FormFieldGroupProps> {
143
140
  <FormFieldLayout
144
141
  {...omitProps(props, FormFieldGroup.allowedProps)}
145
142
  {...pickProps(props, FormFieldLayout.allowedProps)}
146
- // @ts-expect-error ts-migrate(2322) FIXME: Type '{ children: Element; vAlign: "top" | "middle... Remove this comment to see the full error message
147
143
  vAlign={props.vAlign}
148
144
  layout={props.layout === 'inline' ? 'inline' : 'stacked'}
149
145
  label={props.description}
150
- aria-disabled={props.disabled ? 'true' : null}
151
- aria-invalid={this.invalid ? 'true' : null}
146
+ aria-disabled={props.disabled ? 'true' : undefined}
147
+ aria-invalid={this.invalid ? 'true' : undefined}
152
148
  elementRef={this.handleRef}
153
149
  >
154
150
  {this.renderFields()}
@@ -33,12 +33,25 @@ import type {
33
33
  OtherHTMLAttributes
34
34
  } from '@instructure/shared-types'
35
35
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
36
+ import type { FormFieldLayoutOwnProps } from '../FormFieldLayout/props'
36
37
  import type { FormMessage } from '../FormPropTypes'
37
38
 
38
39
  type FormFieldGroupOwnProps = {
39
40
  description: React.ReactNode
41
+ /**
42
+ * the element type to render as
43
+ */
40
44
  as?: AsElementType
45
+ /**
46
+ * Array of objects with shape: `{
47
+ * text: React.ReactNode,
48
+ * type: One of: ['error', 'hint', 'success', 'screenreader-only']
49
+ * }`
50
+ */
41
51
  messages?: FormMessage[]
52
+ /**
53
+ * id for the form field messages
54
+ */
42
55
  messagesId?: string
43
56
  disabled?: boolean
44
57
  children?: React.ReactNode
@@ -46,7 +59,10 @@ type FormFieldGroupOwnProps = {
46
59
  rowSpacing?: 'none' | 'small' | 'medium' | 'large'
47
60
  colSpacing?: 'none' | 'small' | 'medium' | 'large'
48
61
  vAlign?: 'top' | 'middle' | 'bottom'
49
- startAt?: any // TODO: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', null])
62
+ startAt?: 'small' | 'medium' | 'large' | 'x-large' | null
63
+ /**
64
+ * provides a reference to the underlying html root element
65
+ */
50
66
  elementRef?: (element: Element | null) => void
51
67
  }
52
68
 
@@ -60,26 +76,20 @@ type AllowedPropKeys = Readonly<Array<PropKeys>>
60
76
 
61
77
  type FormFieldGroupProps = FormFieldGroupOwnProps &
62
78
  WithStyleProps<FormFieldGroupTheme, FormFieldGroupStyle> &
63
- OtherHTMLAttributes<FormFieldGroupOwnProps>
79
+ OtherHTMLAttributes<FormFieldGroupOwnProps> &
80
+ // Adding other props that can be passed to FormFieldLayout,
81
+ // excluding the ones we set manually
82
+ Omit<
83
+ FormFieldLayoutOwnProps,
84
+ 'messages' | 'messagesId' | 'vAlign' | 'layout' | 'label' | 'children'
85
+ >
64
86
 
65
87
  type FormFieldGroupStyle = ComponentStyle<'formFieldGroup'>
66
88
 
67
89
  const propTypes: PropValidators<PropKeys> = {
68
90
  description: PropTypes.node.isRequired,
69
- /**
70
- * the element type to render as
71
- */
72
91
  as: PropTypes.elementType,
73
- /**
74
- * object with shape: `{
75
- * text: PropTypes.node,
76
- * type: PropTypes.oneOf(['error', 'hint', 'success', 'screenreader-only'])
77
- * }`
78
- */
79
92
  messages: PropTypes.arrayOf(FormPropTypes.message),
80
- /**
81
- * id for the form field messages
82
- */
83
93
  messagesId: PropTypes.string,
84
94
  disabled: PropTypes.bool,
85
95
  children: PropTypes.node,
@@ -88,9 +98,6 @@ const propTypes: PropValidators<PropKeys> = {
88
98
  colSpacing: PropTypes.oneOf(['none', 'small', 'medium', 'large']),
89
99
  vAlign: PropTypes.oneOf(['top', 'middle', 'bottom']),
90
100
  startAt: PropTypes.oneOf(['small', 'medium', 'large', 'x-large', null]),
91
- /**
92
- * provides a reference to the underlying html root element
93
- */
94
101
  elementRef: PropTypes.func
95
102
  }
96
103
 
@@ -38,6 +38,7 @@ import type { FormFieldLabelProps } from './props'
38
38
  ---
39
39
  parent: FormField
40
40
  ---
41
+ @tsProps
41
42
 
42
43
  This is a helper component that is used by most of the custom form
43
44
  components. In most cases it shouldn't be used directly.
@@ -67,14 +68,11 @@ class FormFieldLabel extends Component<FormFieldLabelProps> {
67
68
  }
68
69
 
69
70
  componentDidMount() {
70
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
71
- this.props.makeStyles()
71
+ this.props.makeStyles?.()
72
72
  }
73
73
 
74
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
75
- componentDidUpdate(prevProps, prevState, snapshot) {
76
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
77
- this.props.makeStyles()
74
+ componentDidUpdate() {
75
+ this.props.makeStyles?.()
78
76
  }
79
77
 
80
78
  render() {
@@ -33,8 +33,8 @@ import type {
33
33
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
34
34
 
35
35
  type FormFieldLabelOwnProps = {
36
- as?: AsElementType
37
36
  children: React.ReactNode
37
+ as?: AsElementType
38
38
  }
39
39
 
40
40
  type PropKeys = keyof FormFieldLabelOwnProps
@@ -48,8 +48,8 @@ type FormFieldLabelProps = FormFieldLabelOwnProps &
48
48
  type FormFieldLabelStyle = ComponentStyle<'formFieldLabel'>
49
49
 
50
50
  const propTypes: PropValidators<PropKeys> = {
51
- as: PropTypes.elementType,
52
- children: PropTypes.node.isRequired
51
+ children: PropTypes.node.isRequired,
52
+ as: PropTypes.elementType
53
53
  }
54
54
 
55
55
  const allowedProps: AllowedPropKeys = ['as', 'children']
@@ -50,6 +50,7 @@ import type { FormFieldLayoutProps } from './props'
50
50
  ---
51
51
  parent: FormField
52
52
  ---
53
+ @tsProps
53
54
  **/
54
55
  @withStyle(generateStyle, null)
55
56
  class FormFieldLayout extends Component<FormFieldLayoutProps> {
@@ -58,18 +59,15 @@ class FormFieldLayout extends Component<FormFieldLayoutProps> {
58
59
  static propTypes = propTypes
59
60
  static allowedProps = allowedProps
60
61
  static defaultProps = {
61
- children: null,
62
62
  inline: false,
63
63
  layout: 'stacked',
64
64
  as: 'label',
65
65
  labelAlign: 'end'
66
66
  } as const
67
67
 
68
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'props' implicitly has an 'any' type.
69
- constructor(props) {
68
+ constructor(props: FormFieldLayoutProps) {
70
69
  super(props)
71
70
 
72
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_messagesId' does not exist on type 'For... Remove this comment to see the full error message
73
71
  this._messagesId = props.messagesId || uid('FormFieldLayout-messages')
74
72
 
75
73
  error(
@@ -81,6 +79,8 @@ class FormFieldLayout extends Component<FormFieldLayoutProps> {
81
79
  )
82
80
  }
83
81
 
82
+ private _messagesId: string
83
+
84
84
  ref: Element | null = null
85
85
 
86
86
  handleRef = (el: Element | null) => {
@@ -94,14 +94,11 @@ class FormFieldLayout extends Component<FormFieldLayoutProps> {
94
94
  }
95
95
 
96
96
  componentDidMount() {
97
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
98
- this.props.makeStyles()
97
+ this.props.makeStyles?.()
99
98
  }
100
99
 
101
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
102
- componentDidUpdate(prevProps, prevState, snapshot) {
103
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
104
- this.props.makeStyles()
100
+ componentDidUpdate() {
101
+ this.props.makeStyles?.()
105
102
  }
106
103
 
107
104
  get hasVisibleLabel() {
@@ -121,9 +118,8 @@ class FormFieldLayout extends Component<FormFieldLayoutProps> {
121
118
  return this.props.inline && this.props.layout === 'inline'
122
119
  }
123
120
 
124
- // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'node' implicitly has an 'any' type.
125
- handleInputContainerRef = (node) => {
126
- if (this.props.inputContainerRef) {
121
+ handleInputContainerRef = (node: HTMLSpanElement | null) => {
122
+ if (typeof this.props.inputContainerRef === 'function') {
127
123
  this.props.inputContainerRef(node)
128
124
  }
129
125
  }
@@ -171,7 +167,6 @@ class FormFieldLayout extends Component<FormFieldLayoutProps> {
171
167
  textAlign={this.inlineContainerAndLabel ? 'end' : undefined}
172
168
  >
173
169
  <FormFieldMessages
174
- // @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
175
170
  id={this._messagesId}
176
171
  messages={this.props.messages}
177
172
  />
@@ -194,8 +189,7 @@ class FormFieldLayout extends Component<FormFieldLayoutProps> {
194
189
  ])}
195
190
  css={styles?.formFieldLayout}
196
191
  style={{ width }}
197
- // @ts-expect-error ts-migrate(2339) FIXME: Property '_messagesId' does not exist on type 'For... Remove this comment to see the full error message
198
- aria-describedby={this.hasMessages ? this._messagesId : null}
192
+ aria-describedby={this.hasMessages ? this._messagesId : undefined}
199
193
  ref={this.handleRef}
200
194
  >
201
195
  {this.elementType === 'fieldset' && this.renderLegend()}