@patternfly/react-core 5.0.0-alpha.54 → 5.0.0-alpha.55
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/CHANGELOG.md +6 -0
- package/dist/esm/components/Form/FormGroup.d.ts +0 -16
- package/dist/esm/components/Form/FormGroup.d.ts.map +1 -1
- package/dist/esm/components/Form/FormGroup.js +3 -15
- package/dist/esm/components/Form/FormGroup.js.map +1 -1
- package/dist/esm/components/Form/FormHelperText.d.ts +2 -10
- package/dist/esm/components/Form/FormHelperText.d.ts.map +1 -1
- package/dist/esm/components/Form/FormHelperText.js +2 -5
- package/dist/esm/components/Form/FormHelperText.js.map +1 -1
- package/dist/esm/components/LoginPage/LoginForm.d.ts.map +1 -1
- package/dist/esm/components/LoginPage/LoginForm.js +6 -3
- package/dist/esm/components/LoginPage/LoginForm.js.map +1 -1
- package/dist/js/components/Form/FormGroup.d.ts +0 -16
- package/dist/js/components/Form/FormGroup.d.ts.map +1 -1
- package/dist/js/components/Form/FormGroup.js +3 -15
- package/dist/js/components/Form/FormGroup.js.map +1 -1
- package/dist/js/components/Form/FormHelperText.d.ts +2 -10
- package/dist/js/components/Form/FormHelperText.d.ts.map +1 -1
- package/dist/js/components/Form/FormHelperText.js +2 -5
- package/dist/js/components/Form/FormHelperText.js.map +1 -1
- package/dist/js/components/LoginPage/LoginForm.d.ts.map +1 -1
- package/dist/js/components/LoginPage/LoginForm.js +6 -3
- package/dist/js/components/LoginPage/LoginForm.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/FileUpload/examples/FileUploadTextWithRestrictions.tsx +9 -7
- package/src/components/Form/FormGroup.tsx +1 -60
- package/src/components/Form/FormHelperText.tsx +7 -31
- package/src/components/Form/__tests__/FormGroup.test.tsx +6 -95
- package/src/components/Form/__tests__/FormHelperText.test.tsx +1 -14
- package/src/components/Form/__tests__/__snapshots__/FormGroup.test.tsx.snap +0 -211
- package/src/components/Form/__tests__/__snapshots__/FormHelperText.test.tsx.snap +12 -39
- package/src/components/Form/examples/Form.md +15 -1
- package/src/components/Form/examples/FormBasic.tsx +19 -3
- package/src/components/Form/examples/FormGrid.tsx +16 -7
- package/src/components/Form/examples/FormGroupLabelInfo.tsx +15 -3
- package/src/components/Form/examples/FormHorizontal.tsx +10 -7
- package/src/components/Form/examples/FormHorizontalHelper.tsx +14 -21
- package/src/components/Form/examples/FormInvalid.tsx +11 -14
- package/src/components/Form/examples/FormInvalidWithFormAlert.tsx +20 -14
- package/src/components/Form/examples/FormLimitWidth.tsx +19 -3
- package/src/components/Form/examples/FormValidated.tsx +10 -12
- package/src/components/FormSelect/examples/FormSelectIconSpriteVariant.tsx +17 -11
- package/src/components/FormSelect/examples/FormSelectValidated.tsx +17 -11
- package/src/components/LoginPage/LoginForm.tsx +12 -15
- package/src/components/LoginPage/__tests__/__snapshots__/LoginForm.test.tsx.snap +0 -9
- package/src/components/TextArea/examples/TextAreaValidated.tsx +9 -12
- package/src/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +18 -9
- package/src/components/Wizard/examples/WizardValidateOnButtonPress.tsx +12 -9
- package/src/demos/examples/HelperText/HelperTextDynamicVariantStaticText.tsx +2 -2
- package/src/demos/examples/HelperText/HelperTextStaticVariantDynamicText.tsx +1 -1
- package/src/demos/examples/HelperText/HelperTextStaticVariantStaticText.tsx +1 -1
- package/src/next/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +9 -9
- package/src/next/components/Wizard/examples/WizardValidateOnButtonPress.tsx +12 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.55",
|
|
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",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^17 || ^18",
|
|
71
71
|
"react-dom": "^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "21de59660d27027e268526e8fe05cc359104a32e"
|
|
74
74
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FileUpload, Form, FormGroup } from '@patternfly/react-core';
|
|
2
|
+
import { FileUpload, Form, FormGroup, FormHelperText, HelperText, HelperTextItem } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
4
|
export const TextFileUploadWithRestrictions: React.FunctionComponent = () => {
|
|
5
5
|
const [value, setValue] = React.useState('');
|
|
@@ -35,12 +35,7 @@ export const TextFileUploadWithRestrictions: React.FunctionComponent = () => {
|
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
37
|
<Form>
|
|
38
|
-
<FormGroup
|
|
39
|
-
fieldId="text-file-with-restrictions-example"
|
|
40
|
-
helperText="Upload a CSV file"
|
|
41
|
-
helperTextInvalid="Must be a CSV file no larger than 1 KB"
|
|
42
|
-
validated={isRejected ? 'error' : 'default'}
|
|
43
|
-
>
|
|
38
|
+
<FormGroup fieldId="text-file-with-restrictions-example">
|
|
44
39
|
<FileUpload
|
|
45
40
|
id="text-file-with-restrictions-example"
|
|
46
41
|
type="text"
|
|
@@ -62,6 +57,13 @@ export const TextFileUploadWithRestrictions: React.FunctionComponent = () => {
|
|
|
62
57
|
validated={isRejected ? 'error' : 'default'}
|
|
63
58
|
browseButtonText="Upload"
|
|
64
59
|
/>
|
|
60
|
+
<FormHelperText>
|
|
61
|
+
<HelperText>
|
|
62
|
+
<HelperTextItem variant={isRejected ? 'error' : 'default'}>
|
|
63
|
+
{isRejected ? 'Must be a CSV file no larger than 1 KB' : 'Upload a CSV file'}
|
|
64
|
+
</HelperTextItem>
|
|
65
|
+
</HelperText>
|
|
66
|
+
</FormHelperText>
|
|
65
67
|
</FormGroup>
|
|
66
68
|
</Form>
|
|
67
69
|
);
|
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
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
|
-
import { ValidatedOptions } from '../../helpers/constants';
|
|
6
5
|
import { GenerateId } from '../../helpers/GenerateId/GenerateId';
|
|
7
6
|
|
|
8
7
|
export interface FormGroupProps extends Omit<React.HTMLProps<HTMLDivElement>, 'label'> {
|
|
@@ -18,28 +17,12 @@ export interface FormGroupProps extends Omit<React.HTMLProps<HTMLDivElement>, 'l
|
|
|
18
17
|
labelIcon?: React.ReactElement;
|
|
19
18
|
/** Sets the FormGroup required. */
|
|
20
19
|
isRequired?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Sets the FormGroup validated. If you set to success, text color of helper text will be modified to indicate valid state.
|
|
23
|
-
* If set to error, text color of helper text will be modified to indicate error state.
|
|
24
|
-
* If set to warning, text color of helper text will be modified to indicate warning state.
|
|
25
|
-
*/
|
|
26
|
-
validated?: 'success' | 'warning' | 'error' | 'default';
|
|
27
20
|
/** Sets the FormGroup isInline. */
|
|
28
21
|
isInline?: boolean;
|
|
29
22
|
/** Sets the FormGroupControl to be stacked */
|
|
30
23
|
isStack?: boolean;
|
|
31
24
|
/** Removes top spacer from label. */
|
|
32
25
|
hasNoPaddingTop?: boolean;
|
|
33
|
-
/** Helper text regarding the field. It can be a simple text or an object. */
|
|
34
|
-
helperText?: React.ReactNode;
|
|
35
|
-
/** Flag to position the helper text before the field. False by default */
|
|
36
|
-
isHelperTextBeforeField?: boolean;
|
|
37
|
-
/** Helper text after the field when the field is invalid. It can be a simple text or an object. */
|
|
38
|
-
helperTextInvalid?: React.ReactNode;
|
|
39
|
-
/** Icon displayed to the left of the helper text. */
|
|
40
|
-
helperTextIcon?: React.ReactNode;
|
|
41
|
-
/** Icon displayed to the left of the helper text when the field is invalid. */
|
|
42
|
-
helperTextInvalidIcon?: React.ReactNode;
|
|
43
26
|
/** ID of an individual field or a group of multiple fields. Required when a role of "group" or "radiogroup" is passed in.
|
|
44
27
|
* If only one field is included, its ID attribute and this prop must be the same.
|
|
45
28
|
*/
|
|
@@ -57,53 +40,13 @@ export const FormGroup: React.FunctionComponent<FormGroupProps> = ({
|
|
|
57
40
|
labelInfo,
|
|
58
41
|
labelIcon,
|
|
59
42
|
isRequired = false,
|
|
60
|
-
validated = 'default',
|
|
61
43
|
isInline = false,
|
|
62
44
|
hasNoPaddingTop = false,
|
|
63
45
|
isStack = false,
|
|
64
|
-
helperText,
|
|
65
|
-
isHelperTextBeforeField = false,
|
|
66
|
-
helperTextInvalid,
|
|
67
|
-
helperTextIcon,
|
|
68
|
-
helperTextInvalidIcon,
|
|
69
46
|
fieldId,
|
|
70
47
|
role,
|
|
71
48
|
...props
|
|
72
49
|
}: FormGroupProps) => {
|
|
73
|
-
const validHelperText =
|
|
74
|
-
typeof helperText !== 'string' ? (
|
|
75
|
-
helperText
|
|
76
|
-
) : (
|
|
77
|
-
<div
|
|
78
|
-
className={css(
|
|
79
|
-
styles.formHelperText,
|
|
80
|
-
validated === ValidatedOptions.success && styles.modifiers.success,
|
|
81
|
-
validated === ValidatedOptions.warning && styles.modifiers.warning
|
|
82
|
-
)}
|
|
83
|
-
id={`${fieldId}-helper`}
|
|
84
|
-
aria-live="polite"
|
|
85
|
-
>
|
|
86
|
-
{helperTextIcon && <span className={css(styles.formHelperTextIcon)}>{helperTextIcon}</span>}
|
|
87
|
-
{helperText}
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const inValidHelperText =
|
|
92
|
-
typeof helperTextInvalid !== 'string' ? (
|
|
93
|
-
helperTextInvalid
|
|
94
|
-
) : (
|
|
95
|
-
<div className={css(styles.formHelperText, styles.modifiers.error)} id={`${fieldId}-helper`} aria-live="polite">
|
|
96
|
-
{helperTextInvalidIcon && <span className={css(styles.formHelperTextIcon)}>{helperTextInvalidIcon}</span>}
|
|
97
|
-
{helperTextInvalid}
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const showValidHelperTxt = (validationType: 'success' | 'warning' | 'error' | 'default') =>
|
|
102
|
-
validationType !== ValidatedOptions.error && helperText ? validHelperText : '';
|
|
103
|
-
|
|
104
|
-
const helperTextToDisplay =
|
|
105
|
-
validated === ValidatedOptions.error && helperTextInvalid ? inValidHelperText : showValidHelperTxt(validated);
|
|
106
|
-
|
|
107
50
|
const isGroupOrRadioGroup = role === 'group' || role === 'radiogroup';
|
|
108
51
|
const LabelComponent = isGroupOrRadioGroup ? 'span' : 'label';
|
|
109
52
|
|
|
@@ -124,7 +67,7 @@ export const FormGroup: React.FunctionComponent<FormGroupProps> = ({
|
|
|
124
67
|
|
|
125
68
|
return (
|
|
126
69
|
<GenerateId>
|
|
127
|
-
{randomId => (
|
|
70
|
+
{(randomId) => (
|
|
128
71
|
<div
|
|
129
72
|
className={css(styles.formGroup, className)}
|
|
130
73
|
{...(role && { role })}
|
|
@@ -156,9 +99,7 @@ export const FormGroup: React.FunctionComponent<FormGroupProps> = ({
|
|
|
156
99
|
isStack && styles.modifiers.stack
|
|
157
100
|
)}
|
|
158
101
|
>
|
|
159
|
-
{isHelperTextBeforeField && helperTextToDisplay}
|
|
160
102
|
{children}
|
|
161
|
-
{!isHelperTextBeforeField && helperTextToDisplay}
|
|
162
103
|
</div>
|
|
163
104
|
</div>
|
|
164
105
|
)}
|
|
@@ -3,43 +3,19 @@ import { css } from '@patternfly/react-styles';
|
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Form/form';
|
|
4
4
|
|
|
5
5
|
export interface FormHelperTextProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
-
/** Content rendered inside the
|
|
6
|
+
/** Content rendered inside the helper text wrapper */
|
|
7
7
|
children?: React.ReactNode;
|
|
8
|
-
/**
|
|
9
|
-
isError?: boolean;
|
|
10
|
-
/** Hides the helper text * */
|
|
11
|
-
isHidden?: boolean;
|
|
12
|
-
/** Additional classes added to the Helper Text Item */
|
|
8
|
+
/** Additional classes added to the helper text wrapper */
|
|
13
9
|
className?: string;
|
|
14
|
-
/** Icon displayed to the left of the helper text. */
|
|
15
|
-
icon?: React.ReactNode;
|
|
16
|
-
/** Component type of the form helper text */
|
|
17
|
-
component?: 'p' | 'div';
|
|
18
10
|
}
|
|
19
11
|
|
|
20
12
|
export const FormHelperText: React.FunctionComponent<FormHelperTextProps> = ({
|
|
21
13
|
children = null,
|
|
22
|
-
isError = false,
|
|
23
|
-
isHidden = true,
|
|
24
14
|
className = '',
|
|
25
|
-
icon = null,
|
|
26
|
-
component = 'p',
|
|
27
15
|
...props
|
|
28
|
-
}: FormHelperTextProps) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
styles.formHelperText,
|
|
34
|
-
isError && styles.modifiers.error,
|
|
35
|
-
isHidden && styles.modifiers.hidden,
|
|
36
|
-
className
|
|
37
|
-
)}
|
|
38
|
-
{...props}
|
|
39
|
-
>
|
|
40
|
-
{icon && <span className={css(styles.formHelperTextIcon)}>{icon}</span>}
|
|
41
|
-
{children}
|
|
42
|
-
</Component>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
16
|
+
}: FormHelperTextProps) => (
|
|
17
|
+
<div className={css(styles.formHelperText, className)} {...props}>
|
|
18
|
+
{children}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
45
21
|
FormHelperText.displayName = 'FormHelperText';
|
|
@@ -12,7 +12,7 @@ describe('FormGroup', () => {
|
|
|
12
12
|
|
|
13
13
|
test('should render default form group variant', () => {
|
|
14
14
|
const { asFragment } = render(
|
|
15
|
-
<FormGroup label="label" fieldId="label-id"
|
|
15
|
+
<FormGroup label="label" fieldId="label-id">
|
|
16
16
|
<input id="label-id" />
|
|
17
17
|
</FormGroup>
|
|
18
18
|
);
|
|
@@ -21,7 +21,7 @@ describe('FormGroup', () => {
|
|
|
21
21
|
|
|
22
22
|
test('should render inline form group variant', () => {
|
|
23
23
|
render(
|
|
24
|
-
<FormGroup isInline label="label" fieldId="label-id"
|
|
24
|
+
<FormGroup isInline label="label" fieldId="label-id">
|
|
25
25
|
<input id="label-id" />
|
|
26
26
|
</FormGroup>
|
|
27
27
|
);
|
|
@@ -30,13 +30,7 @@ describe('FormGroup', () => {
|
|
|
30
30
|
|
|
31
31
|
test('should render no padding-top form group variant', () => {
|
|
32
32
|
render(
|
|
33
|
-
<FormGroup
|
|
34
|
-
hasNoPaddingTop
|
|
35
|
-
label="label"
|
|
36
|
-
fieldId="label-id"
|
|
37
|
-
helperText="this is helper text"
|
|
38
|
-
data-testid="form-group-test-id"
|
|
39
|
-
>
|
|
33
|
+
<FormGroup hasNoPaddingTop label="label" fieldId="label-id" data-testid="form-group-test-id">
|
|
40
34
|
<input id="label-id" />
|
|
41
35
|
</FormGroup>
|
|
42
36
|
);
|
|
@@ -80,30 +74,10 @@ describe('FormGroup', () => {
|
|
|
80
74
|
expect(screen.getByText('label')).toBeInTheDocument();
|
|
81
75
|
});
|
|
82
76
|
|
|
83
|
-
test('should render form group variant with node helperText', () => {
|
|
84
|
-
render(
|
|
85
|
-
<FormGroup label="Label" fieldId="label-id" helperText={<h1>Header</h1>}>
|
|
86
|
-
<input id="label-id" />
|
|
87
|
-
</FormGroup>
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
expect(screen.getByRole('heading', { name: 'Header' })).toBeInTheDocument();
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('should render form group variant with function helperText', () => {
|
|
94
|
-
render(
|
|
95
|
-
<FormGroup label="Label" fieldId="label-id" helperText={returnFunction()}>
|
|
96
|
-
<input id="label-id" />
|
|
97
|
-
</FormGroup>
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
expect(screen.getByText('label')).toBeInTheDocument();
|
|
101
|
-
});
|
|
102
|
-
|
|
103
77
|
test('should render horizontal form group variant', () => {
|
|
104
78
|
const { asFragment } = render(
|
|
105
79
|
<Form isHorizontal>
|
|
106
|
-
<FormGroup label="label" fieldId="label-id"
|
|
80
|
+
<FormGroup label="label" fieldId="label-id">
|
|
107
81
|
<input id="label-id" />
|
|
108
82
|
</FormGroup>
|
|
109
83
|
</Form>
|
|
@@ -114,18 +88,7 @@ describe('FormGroup', () => {
|
|
|
114
88
|
test('should render stacked horizontal form group variant', () => {
|
|
115
89
|
const { asFragment } = render(
|
|
116
90
|
<Form isHorizontal>
|
|
117
|
-
<FormGroup label="label" fieldId="label-id" isStack
|
|
118
|
-
<input id="label-id" />
|
|
119
|
-
</FormGroup>
|
|
120
|
-
</Form>
|
|
121
|
-
);
|
|
122
|
-
expect(asFragment()).toMatchSnapshot();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test('should render helper text above input', () => {
|
|
126
|
-
const { asFragment } = render(
|
|
127
|
-
<Form isHorizontal>
|
|
128
|
-
<FormGroup label="label" fieldId="label-id" helperText="this is helperText" isHelperTextBeforeField>
|
|
91
|
+
<FormGroup label="label" fieldId="label-id" isStack>
|
|
129
92
|
<input id="label-id" />
|
|
130
93
|
</FormGroup>
|
|
131
94
|
</Form>
|
|
@@ -142,58 +105,6 @@ describe('FormGroup', () => {
|
|
|
142
105
|
expect(asFragment()).toMatchSnapshot();
|
|
143
106
|
});
|
|
144
107
|
|
|
145
|
-
test('should render form group invalid variant', () => {
|
|
146
|
-
const { asFragment } = render(
|
|
147
|
-
<FormGroup label="label" fieldId="label-id" validated={'error'} helperTextInvalid="Invalid FormGroup">
|
|
148
|
-
<input id="id" />
|
|
149
|
-
</FormGroup>
|
|
150
|
-
);
|
|
151
|
-
expect(asFragment()).toMatchSnapshot();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test('should render form group validated success variant', () => {
|
|
155
|
-
const { asFragment } = render(
|
|
156
|
-
<FormGroup
|
|
157
|
-
label="label"
|
|
158
|
-
fieldId="label-id"
|
|
159
|
-
validated={ValidatedOptions.success}
|
|
160
|
-
helperText="Validated FormGroup"
|
|
161
|
-
data-testid="form-group-test-id"
|
|
162
|
-
>
|
|
163
|
-
<input id="id" />
|
|
164
|
-
</FormGroup>
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
expect(screen.getByTestId('form-group-test-id').querySelector('input + div')).toHaveClass('pf-m-success');
|
|
168
|
-
expect(asFragment()).toMatchSnapshot();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
test('should render form group validated error variant', () => {
|
|
172
|
-
const { asFragment } = render(
|
|
173
|
-
<FormGroup label="label" fieldId="label-id" validated={ValidatedOptions.error} helperText="Validated FormGroup">
|
|
174
|
-
<input id="id" />
|
|
175
|
-
</FormGroup>
|
|
176
|
-
);
|
|
177
|
-
expect(asFragment()).toMatchSnapshot();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test('should render form group validated warning variant', () => {
|
|
181
|
-
const { asFragment } = render(
|
|
182
|
-
<FormGroup
|
|
183
|
-
label="label"
|
|
184
|
-
fieldId="label-id"
|
|
185
|
-
validated={ValidatedOptions.warning}
|
|
186
|
-
helperText="Validated FormGroup"
|
|
187
|
-
data-testid="form-group-test-id"
|
|
188
|
-
>
|
|
189
|
-
<input id="id" />
|
|
190
|
-
</FormGroup>
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
expect(screen.getByTestId('form-group-test-id').querySelector('input + div')).toHaveClass('pf-m-warning');
|
|
194
|
-
expect(asFragment()).toMatchSnapshot();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
108
|
test('should render correctly when label is not a string with Children = Array', () => {
|
|
198
109
|
const { asFragment } = render(
|
|
199
110
|
<FormGroup fieldId="id" label={returnFunction()}>
|
|
@@ -245,7 +156,7 @@ describe('FormGroup', () => {
|
|
|
245
156
|
const inputs = screen.getAllByRole('textbox');
|
|
246
157
|
|
|
247
158
|
await user.click(labelElement);
|
|
248
|
-
inputs.forEach(input => {
|
|
159
|
+
inputs.forEach((input) => {
|
|
249
160
|
expect(input).not.toHaveFocus();
|
|
250
161
|
});
|
|
251
162
|
});
|
|
@@ -7,20 +7,7 @@ import { FormHelperText } from '../FormHelperText';
|
|
|
7
7
|
|
|
8
8
|
describe('FormHelperText', () => {
|
|
9
9
|
test('renders with PatternFly Core styles', () => {
|
|
10
|
-
const { asFragment } = render(
|
|
11
|
-
<FormHelperText isError isHidden={false}>
|
|
12
|
-
test
|
|
13
|
-
</FormHelperText>
|
|
14
|
-
);
|
|
15
|
-
expect(asFragment()).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('renders with icon', () => {
|
|
19
|
-
const { asFragment } = render(
|
|
20
|
-
<FormHelperText isError isHidden={false} icon={<ExclamationCircleIcon />}>
|
|
21
|
-
test
|
|
22
|
-
</FormHelperText>
|
|
23
|
-
);
|
|
10
|
+
const { asFragment } = render(<FormHelperText>test</FormHelperText>);
|
|
24
11
|
expect(asFragment()).toMatchSnapshot();
|
|
25
12
|
});
|
|
26
13
|
|
|
@@ -63,160 +63,6 @@ exports[`FormGroup should render default form group variant 1`] = `
|
|
|
63
63
|
<input
|
|
64
64
|
id="label-id"
|
|
65
65
|
/>
|
|
66
|
-
<div
|
|
67
|
-
aria-live="polite"
|
|
68
|
-
class="pf-c-form__helper-text"
|
|
69
|
-
id="label-id-helper"
|
|
70
|
-
>
|
|
71
|
-
this is helper text
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
</DocumentFragment>
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
exports[`FormGroup should render form group invalid variant 1`] = `
|
|
79
|
-
<DocumentFragment>
|
|
80
|
-
<div
|
|
81
|
-
class="pf-c-form__group"
|
|
82
|
-
>
|
|
83
|
-
<div
|
|
84
|
-
class="pf-c-form__group-label"
|
|
85
|
-
>
|
|
86
|
-
<label
|
|
87
|
-
class="pf-c-form__label"
|
|
88
|
-
for="label-id"
|
|
89
|
-
>
|
|
90
|
-
<span
|
|
91
|
-
class="pf-c-form__label-text"
|
|
92
|
-
>
|
|
93
|
-
label
|
|
94
|
-
</span>
|
|
95
|
-
</label>
|
|
96
|
-
|
|
97
|
-
</div>
|
|
98
|
-
<div
|
|
99
|
-
class="pf-c-form__group-control"
|
|
100
|
-
>
|
|
101
|
-
<input
|
|
102
|
-
id="id"
|
|
103
|
-
/>
|
|
104
|
-
<div
|
|
105
|
-
aria-live="polite"
|
|
106
|
-
class="pf-c-form__helper-text pf-m-error"
|
|
107
|
-
id="label-id-helper"
|
|
108
|
-
>
|
|
109
|
-
Invalid FormGroup
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
</DocumentFragment>
|
|
114
|
-
`;
|
|
115
|
-
|
|
116
|
-
exports[`FormGroup should render form group validated error variant 1`] = `
|
|
117
|
-
<DocumentFragment>
|
|
118
|
-
<div
|
|
119
|
-
class="pf-c-form__group"
|
|
120
|
-
>
|
|
121
|
-
<div
|
|
122
|
-
class="pf-c-form__group-label"
|
|
123
|
-
>
|
|
124
|
-
<label
|
|
125
|
-
class="pf-c-form__label"
|
|
126
|
-
for="label-id"
|
|
127
|
-
>
|
|
128
|
-
<span
|
|
129
|
-
class="pf-c-form__label-text"
|
|
130
|
-
>
|
|
131
|
-
label
|
|
132
|
-
</span>
|
|
133
|
-
</label>
|
|
134
|
-
|
|
135
|
-
</div>
|
|
136
|
-
<div
|
|
137
|
-
class="pf-c-form__group-control"
|
|
138
|
-
>
|
|
139
|
-
<input
|
|
140
|
-
id="id"
|
|
141
|
-
/>
|
|
142
|
-
</div>
|
|
143
|
-
</div>
|
|
144
|
-
</DocumentFragment>
|
|
145
|
-
`;
|
|
146
|
-
|
|
147
|
-
exports[`FormGroup should render form group validated success variant 1`] = `
|
|
148
|
-
<DocumentFragment>
|
|
149
|
-
<div
|
|
150
|
-
class="pf-c-form__group"
|
|
151
|
-
data-testid="form-group-test-id"
|
|
152
|
-
>
|
|
153
|
-
<div
|
|
154
|
-
class="pf-c-form__group-label"
|
|
155
|
-
>
|
|
156
|
-
<label
|
|
157
|
-
class="pf-c-form__label"
|
|
158
|
-
for="label-id"
|
|
159
|
-
>
|
|
160
|
-
<span
|
|
161
|
-
class="pf-c-form__label-text"
|
|
162
|
-
>
|
|
163
|
-
label
|
|
164
|
-
</span>
|
|
165
|
-
</label>
|
|
166
|
-
|
|
167
|
-
</div>
|
|
168
|
-
<div
|
|
169
|
-
class="pf-c-form__group-control"
|
|
170
|
-
>
|
|
171
|
-
<input
|
|
172
|
-
id="id"
|
|
173
|
-
/>
|
|
174
|
-
<div
|
|
175
|
-
aria-live="polite"
|
|
176
|
-
class="pf-c-form__helper-text pf-m-success"
|
|
177
|
-
id="label-id-helper"
|
|
178
|
-
>
|
|
179
|
-
Validated FormGroup
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
</div>
|
|
183
|
-
</DocumentFragment>
|
|
184
|
-
`;
|
|
185
|
-
|
|
186
|
-
exports[`FormGroup should render form group validated warning variant 1`] = `
|
|
187
|
-
<DocumentFragment>
|
|
188
|
-
<div
|
|
189
|
-
class="pf-c-form__group"
|
|
190
|
-
data-testid="form-group-test-id"
|
|
191
|
-
>
|
|
192
|
-
<div
|
|
193
|
-
class="pf-c-form__group-label"
|
|
194
|
-
>
|
|
195
|
-
<label
|
|
196
|
-
class="pf-c-form__label"
|
|
197
|
-
for="label-id"
|
|
198
|
-
>
|
|
199
|
-
<span
|
|
200
|
-
class="pf-c-form__label-text"
|
|
201
|
-
>
|
|
202
|
-
label
|
|
203
|
-
</span>
|
|
204
|
-
</label>
|
|
205
|
-
|
|
206
|
-
</div>
|
|
207
|
-
<div
|
|
208
|
-
class="pf-c-form__group-control"
|
|
209
|
-
>
|
|
210
|
-
<input
|
|
211
|
-
id="id"
|
|
212
|
-
/>
|
|
213
|
-
<div
|
|
214
|
-
aria-live="polite"
|
|
215
|
-
class="pf-c-form__helper-text pf-m-warning"
|
|
216
|
-
id="label-id-helper"
|
|
217
|
-
>
|
|
218
|
-
Validated FormGroup
|
|
219
|
-
</div>
|
|
220
66
|
</div>
|
|
221
67
|
</div>
|
|
222
68
|
</DocumentFragment>
|
|
@@ -350,49 +196,6 @@ exports[`FormGroup should render form group with additonal label info 1`] = `
|
|
|
350
196
|
</DocumentFragment>
|
|
351
197
|
`;
|
|
352
198
|
|
|
353
|
-
exports[`FormGroup should render helper text above input 1`] = `
|
|
354
|
-
<DocumentFragment>
|
|
355
|
-
<form
|
|
356
|
-
class="pf-c-form pf-m-horizontal"
|
|
357
|
-
novalidate=""
|
|
358
|
-
>
|
|
359
|
-
<div
|
|
360
|
-
class="pf-c-form__group"
|
|
361
|
-
>
|
|
362
|
-
<div
|
|
363
|
-
class="pf-c-form__group-label"
|
|
364
|
-
>
|
|
365
|
-
<label
|
|
366
|
-
class="pf-c-form__label"
|
|
367
|
-
for="label-id"
|
|
368
|
-
>
|
|
369
|
-
<span
|
|
370
|
-
class="pf-c-form__label-text"
|
|
371
|
-
>
|
|
372
|
-
label
|
|
373
|
-
</span>
|
|
374
|
-
</label>
|
|
375
|
-
|
|
376
|
-
</div>
|
|
377
|
-
<div
|
|
378
|
-
class="pf-c-form__group-control"
|
|
379
|
-
>
|
|
380
|
-
<div
|
|
381
|
-
aria-live="polite"
|
|
382
|
-
class="pf-c-form__helper-text"
|
|
383
|
-
id="label-id-helper"
|
|
384
|
-
>
|
|
385
|
-
this is helperText
|
|
386
|
-
</div>
|
|
387
|
-
<input
|
|
388
|
-
id="label-id"
|
|
389
|
-
/>
|
|
390
|
-
</div>
|
|
391
|
-
</div>
|
|
392
|
-
</form>
|
|
393
|
-
</DocumentFragment>
|
|
394
|
-
`;
|
|
395
|
-
|
|
396
199
|
exports[`FormGroup should render horizontal form group variant 1`] = `
|
|
397
200
|
<DocumentFragment>
|
|
398
201
|
<form
|
|
@@ -423,13 +226,6 @@ exports[`FormGroup should render horizontal form group variant 1`] = `
|
|
|
423
226
|
<input
|
|
424
227
|
id="label-id"
|
|
425
228
|
/>
|
|
426
|
-
<div
|
|
427
|
-
aria-live="polite"
|
|
428
|
-
class="pf-c-form__helper-text"
|
|
429
|
-
id="label-id-helper"
|
|
430
|
-
>
|
|
431
|
-
this is helperText
|
|
432
|
-
</div>
|
|
433
229
|
</div>
|
|
434
230
|
</div>
|
|
435
231
|
</form>
|
|
@@ -466,13 +262,6 @@ exports[`FormGroup should render stacked horizontal form group variant 1`] = `
|
|
|
466
262
|
<input
|
|
467
263
|
id="label-id"
|
|
468
264
|
/>
|
|
469
|
-
<div
|
|
470
|
-
aria-live="polite"
|
|
471
|
-
class="pf-c-form__helper-text"
|
|
472
|
-
id="label-id-helper"
|
|
473
|
-
>
|
|
474
|
-
this is helperText
|
|
475
|
-
</div>
|
|
476
265
|
</div>
|
|
477
266
|
</div>
|
|
478
267
|
</form>
|
|
@@ -2,59 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`FormHelperText LoginFooterItem with custom node 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
|
-
<
|
|
6
|
-
class="pf-c-form__helper-text
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
<div
|
|
6
|
+
class="pf-c-form__helper-text"
|
|
7
|
+
>
|
|
8
|
+
<div>
|
|
9
|
+
My custom node
|
|
10
|
+
</div>
|
|
10
11
|
</div>
|
|
11
|
-
<p />
|
|
12
12
|
</DocumentFragment>
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
15
|
exports[`FormHelperText className is added to the root element 1`] = `
|
|
16
16
|
<DocumentFragment>
|
|
17
|
-
<
|
|
18
|
-
class="pf-c-form__helper-text
|
|
17
|
+
<div
|
|
18
|
+
class="pf-c-form__helper-text extra-class"
|
|
19
19
|
>
|
|
20
20
|
test
|
|
21
|
-
</
|
|
21
|
+
</div>
|
|
22
22
|
</DocumentFragment>
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
25
|
exports[`FormHelperText renders with PatternFly Core styles 1`] = `
|
|
26
26
|
<DocumentFragment>
|
|
27
|
-
<
|
|
28
|
-
class="pf-c-form__helper-text
|
|
27
|
+
<div
|
|
28
|
+
class="pf-c-form__helper-text"
|
|
29
29
|
>
|
|
30
30
|
test
|
|
31
|
-
</
|
|
32
|
-
</DocumentFragment>
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
exports[`FormHelperText renders with icon 1`] = `
|
|
36
|
-
<DocumentFragment>
|
|
37
|
-
<p
|
|
38
|
-
class="pf-c-form__helper-text pf-m-error"
|
|
39
|
-
>
|
|
40
|
-
<span
|
|
41
|
-
class="pf-c-form__helper-text-icon"
|
|
42
|
-
>
|
|
43
|
-
<svg
|
|
44
|
-
aria-hidden="true"
|
|
45
|
-
fill="currentColor"
|
|
46
|
-
height="1em"
|
|
47
|
-
role="img"
|
|
48
|
-
style="vertical-align: -0.125em;"
|
|
49
|
-
viewBox="0 0 512 512"
|
|
50
|
-
width="1em"
|
|
51
|
-
>
|
|
52
|
-
<path
|
|
53
|
-
d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"
|
|
54
|
-
/>
|
|
55
|
-
</svg>
|
|
56
|
-
</span>
|
|
57
|
-
test
|
|
58
|
-
</p>
|
|
31
|
+
</div>
|
|
59
32
|
</DocumentFragment>
|
|
60
33
|
`;
|