@patternfly/react-core 4.223.2 → 4.223.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.223.2",
3
+ "version": "4.223.3",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -34,16 +34,16 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.74.2",
38
- "@patternfly/react-styles": "^4.73.2",
39
- "@patternfly/react-tokens": "^4.75.2",
37
+ "@patternfly/react-icons": "^4.74.3",
38
+ "@patternfly/react-styles": "^4.73.3",
39
+ "@patternfly/react-tokens": "^4.75.3",
40
40
  "focus-trap": "6.9.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
43
43
  "tslib": "^2.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@patternfly/patternfly": "4.202.0",
46
+ "@patternfly/patternfly": "4.202.1",
47
47
  "@rollup/plugin-commonjs": "^21.0.0",
48
48
  "@rollup/plugin-node-resolve": "^13.0.0",
49
49
  "@rollup/plugin-replace": "^3.0.0",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },
63
- "gitHead": "9370d34d7fa3daf58059aca057be4fd7a5d33a55"
63
+ "gitHead": "4a38be0bce3d08537de52cbd42415611c0a2b218"
64
64
  }
@@ -3,6 +3,7 @@ import styles from '@patternfly/react-styles/css/components/Form/form';
3
3
  import { ASTERISK } from '../../helpers/htmlConstants';
4
4
  import { css } from '@patternfly/react-styles';
5
5
  import { ValidatedOptions } from '../../helpers/constants';
6
+ import { GenerateId } from '../../helpers/GenerateId/GenerateId';
6
7
 
7
8
  export interface FormGroupProps extends Omit<React.HTMLProps<HTMLDivElement>, 'label'> {
8
9
  /** Anything that can be rendered as FormGroup content. */
@@ -39,8 +40,10 @@ export interface FormGroupProps extends Omit<React.HTMLProps<HTMLDivElement>, 'l
39
40
  helperTextIcon?: React.ReactNode;
40
41
  /** Icon displayed to the left of the helper text when the field is invalid. */
41
42
  helperTextInvalidIcon?: React.ReactNode;
42
- /** ID of the included field. It has to be the same for proper working. */
43
- fieldId: string;
43
+ /** ID of an individual field or a group of multiple fields. Required when a role of "group" or "radiogroup" is passed in.
44
+ * If only one field is included, its ID attribute and this prop must be the same.
45
+ */
46
+ fieldId?: string;
44
47
  /** Sets the role of the form group. Pass in "radiogroup" when the form group contains multiple
45
48
  * radio inputs, or pass in "group" when the form group contains multiple of any other input type.
46
49
  */
@@ -120,38 +123,46 @@ export const FormGroup: React.FunctionComponent<FormGroupProps> = ({
120
123
  );
121
124
 
122
125
  return (
123
- <div
124
- className={css(styles.formGroup, className)}
125
- {...(role && { role })}
126
- {...(isGroupOrRadioGroup && { 'aria-labelledby': `${fieldId}-legend` })}
127
- {...props}
128
- >
129
- {label && (
126
+ <GenerateId>
127
+ {randomId => (
130
128
  <div
131
- className={css(
132
- styles.formGroupLabel,
133
- labelInfo && styles.modifiers.info,
134
- hasNoPaddingTop && styles.modifiers.noPaddingTop
135
- )}
136
- {...(isGroupOrRadioGroup && { id: `${fieldId}-legend` })}
129
+ className={css(styles.formGroup, className)}
130
+ {...(role && { role })}
131
+ {...(isGroupOrRadioGroup && { 'aria-labelledby': `${fieldId || randomId}-legend` })}
132
+ {...props}
137
133
  >
138
- {labelInfo && (
139
- <React.Fragment>
140
- <div className={css(styles.formGroupLabelMain)}>{labelContent}</div>
141
- <div className={css(styles.formGroupLabelInfo)}>{labelInfo}</div>
142
- </React.Fragment>
134
+ {label && (
135
+ <div
136
+ className={css(
137
+ styles.formGroupLabel,
138
+ labelInfo && styles.modifiers.info,
139
+ hasNoPaddingTop && styles.modifiers.noPaddingTop
140
+ )}
141
+ {...(isGroupOrRadioGroup && { id: `${fieldId || randomId}-legend` })}
142
+ >
143
+ {labelInfo && (
144
+ <React.Fragment>
145
+ <div className={css(styles.formGroupLabelMain)}>{labelContent}</div>
146
+ <div className={css(styles.formGroupLabelInfo)}>{labelInfo}</div>
147
+ </React.Fragment>
148
+ )}
149
+ {!labelInfo && labelContent}
150
+ </div>
143
151
  )}
144
- {!labelInfo && labelContent}
152
+ <div
153
+ className={css(
154
+ styles.formGroupControl,
155
+ isInline && styles.modifiers.inline,
156
+ isStack && styles.modifiers.stack
157
+ )}
158
+ >
159
+ {isHelperTextBeforeField && helperTextToDisplay}
160
+ {children}
161
+ {!isHelperTextBeforeField && helperTextToDisplay}
162
+ </div>
145
163
  </div>
146
164
  )}
147
- <div
148
- className={css(styles.formGroupControl, isInline && styles.modifiers.inline, isStack && styles.modifiers.stack)}
149
- >
150
- {isHelperTextBeforeField && helperTextToDisplay}
151
- {children}
152
- {!isHelperTextBeforeField && helperTextToDisplay}
153
- </div>
154
- </div>
165
+ </GenerateId>
155
166
  );
156
167
  };
157
168
  FormGroup.displayName = 'FormGroup';