@patternfly/react-core 4.251.2 → 4.251.4
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 +16 -0
- package/dist/styles/assets/pficon/pficon.scss +6 -0
- package/dist/styles/assets/pficon/pficon.woff +0 -0
- package/dist/styles/assets/pficon/pficon.woff2 +0 -0
- package/dist/styles/base-no-reset.css +5 -0
- package/dist/styles/base.css +5 -0
- package/dist/umd/react-core.min.css +610 -610
- package/package.json +6 -6
- package/src/components/TextArea/__tests__/TextArea.test.tsx +129 -113
- package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +5 -120
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.251.
|
|
3
|
+
"version": "4.251.4",
|
|
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",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"generate": "node scripts/copyStyles.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@patternfly/react-icons": "^4.92.
|
|
48
|
-
"@patternfly/react-styles": "^4.91.
|
|
49
|
-
"@patternfly/react-tokens": "^4.93.
|
|
47
|
+
"@patternfly/react-icons": "^4.92.7",
|
|
48
|
+
"@patternfly/react-styles": "^4.91.7",
|
|
49
|
+
"@patternfly/react-tokens": "^4.93.7",
|
|
50
50
|
"focus-trap": "6.9.2",
|
|
51
51
|
"react-dropzone": "9.0.0",
|
|
52
52
|
"tippy.js": "5.1.2",
|
|
53
53
|
"tslib": "^2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@patternfly/patternfly": "4.
|
|
56
|
+
"@patternfly/patternfly": "4.218.0",
|
|
57
57
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
58
58
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
59
59
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8 || ^17 || ^18",
|
|
71
71
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "449291fb1b567dc14afd99890cda544bfbe5f4ba"
|
|
74
74
|
}
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
4
|
import userEvent from '@testing-library/user-event';
|
|
5
5
|
|
|
6
|
-
import { TextArea
|
|
6
|
+
import { TextArea } from '../TextArea';
|
|
7
7
|
import { ValidatedOptions } from '../../../helpers/constants';
|
|
8
8
|
|
|
9
9
|
const props = {
|
|
@@ -11,116 +11,132 @@ const props = {
|
|
|
11
11
|
value: 'test textarea'
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
14
|
+
test('Textarea input passes value and event to onChange handler', async () => {
|
|
15
|
+
const user = userEvent.setup();
|
|
16
|
+
render(<TextArea {...props} value="" aria-label="test textarea" />);
|
|
17
|
+
|
|
18
|
+
await user.type(screen.getByRole('textbox'), 'a');
|
|
19
|
+
|
|
20
|
+
expect(props.onChange).toHaveBeenCalledWith('a', expect.any(Object));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Renders simple text input', () => {
|
|
24
|
+
render(
|
|
25
|
+
<div data-testid="textarea">
|
|
26
|
+
<TextArea aria-label="simple textarea" />
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
expect(screen.getByTestId('textarea').firstChild).toBeVisible();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('Renders with custom class passed', () => {
|
|
33
|
+
render(<TextArea aria-label="custom class textarea" className="test-class" />);
|
|
34
|
+
|
|
35
|
+
expect(screen.getByRole('textbox')).toHaveClass('test-class');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('Renders text area with required attribute using isRequired', () => {
|
|
39
|
+
render(<TextArea aria-label="required textarea" isRequired />);
|
|
40
|
+
|
|
41
|
+
expect(screen.getByRole('textbox')).toBeRequired();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('Text area is not required by default', () => {
|
|
45
|
+
render(<TextArea aria-label="not required textarea" />);
|
|
46
|
+
|
|
47
|
+
expect(screen.getByRole('textbox')).not.toBeRequired();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('Renders disabled text area using isDisabled', () => {
|
|
51
|
+
render(<TextArea aria-label="is disabled textarea" isDisabled />);
|
|
52
|
+
expect(screen.getByRole('textbox')).toBeDisabled();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('Text area is not disabled by default', () => {
|
|
56
|
+
render(<TextArea aria-label="not disabled textarea" />);
|
|
57
|
+
expect(screen.getByRole('textbox')).not.toBeDisabled();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('Renders read only text area using readOnlyVariant', () => {
|
|
61
|
+
render(<TextArea aria-label="is read only textarea" readOnlyVariant={'default'} />);
|
|
62
|
+
expect(screen.getByRole('textbox')).toHaveAttribute('readonly');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('Text area is not read only by default', () => {
|
|
66
|
+
render(<TextArea aria-label="not read only textarea" />);
|
|
67
|
+
expect(screen.getByRole('textbox')).not.toHaveAttribute('readonly');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('Renders text area with default class name only', () => {
|
|
71
|
+
render(<TextArea aria-label="validated textarea" />);
|
|
72
|
+
expect(screen.getByRole('textbox')).toHaveClass('pf-c-form-control', { exact: true });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('Renders validated text area with success className', () => {
|
|
76
|
+
render(<TextArea aria-label="validated textarea" validated={ValidatedOptions.success} />);
|
|
77
|
+
expect(screen.getByRole('textbox')).toHaveClass('pf-m-success');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('Renders validated text area with warning className', () => {
|
|
81
|
+
render(<TextArea aria-label="validated textarea" validated={ValidatedOptions.warning} />);
|
|
82
|
+
expect(screen.getByRole('textbox')).toHaveClass('pf-m-warning');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('Renders invalid text area', () => {
|
|
86
|
+
render(<TextArea aria-label="validated textarea" validated={ValidatedOptions.error} />);
|
|
87
|
+
expect(screen.getByRole('textbox')).toBeInvalid();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('Text area is not invalid by default', () => {
|
|
91
|
+
render(<TextArea aria-label="validated textarea" />);
|
|
92
|
+
expect(screen.getByRole('textbox')).not.toBeInvalid();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('Renders vertically resizable text area', () => {
|
|
96
|
+
render(<TextArea aria-label="vertical resize textarea" resizeOrientation="vertical" />);
|
|
97
|
+
expect(screen.getByRole('textbox')).toHaveClass('pf-m-resize-vertical');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('Renders horizontally resizable text area', () => {
|
|
101
|
+
render(<TextArea aria-label="horizontal resize textarea" resizeOrientation="horizontal" />);
|
|
102
|
+
expect(screen.getByRole('textbox')).toHaveClass('pf-m-resize-horizontal');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('Throws console error when no aria-label or id is given', () => {
|
|
106
|
+
jest.spyOn(global.console, 'error');
|
|
107
|
+
|
|
108
|
+
render(<TextArea />);
|
|
109
|
+
|
|
110
|
+
expect(console.error).toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('Does not throw console error when id is given but no aria-label', () => {
|
|
114
|
+
jest.spyOn(global.console, 'error');
|
|
115
|
+
|
|
116
|
+
render(<TextArea id="5" />);
|
|
117
|
+
|
|
118
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('Does not throw console error when aria-label is given but no id', () => {
|
|
122
|
+
jest.spyOn(global.console, 'error');
|
|
123
|
+
|
|
124
|
+
render(<TextArea aria-label="test textarea" />);
|
|
125
|
+
|
|
126
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('TextArea can be accessed via passed ref', () => {
|
|
130
|
+
const testRef: React.RefObject<HTMLTextAreaElement> = React.createRef();
|
|
131
|
+
render(<TextArea ref={testRef} />);
|
|
132
|
+
global.scrollTo = jest.fn();
|
|
133
|
+
testRef.current?.focus();
|
|
134
|
+
expect(screen.getByRole('textbox')).toHaveFocus();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('Matches the snapshot', () => {
|
|
138
|
+
const { asFragment } = render(
|
|
139
|
+
<TextArea className="custom class" isRequired isDisabled autoResize aria-label="test textarea" />
|
|
140
|
+
);
|
|
141
|
+
expect(asFragment()).toMatchSnapshot();
|
|
126
142
|
});
|
|
@@ -1,129 +1,14 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`Matches the snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<textarea
|
|
6
6
|
aria-invalid="false"
|
|
7
|
-
aria-label="
|
|
8
|
-
class="pf-c-form-control"
|
|
7
|
+
aria-label="test textarea"
|
|
8
|
+
class="pf-c-form-control custom class"
|
|
9
9
|
disabled=""
|
|
10
|
-
>
|
|
11
|
-
test textarea
|
|
12
|
-
</textarea>
|
|
13
|
-
</DocumentFragment>
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
exports[`TextArea disabled text area using isDisabled 1`] = `
|
|
17
|
-
<DocumentFragment>
|
|
18
|
-
<textarea
|
|
19
|
-
aria-invalid="false"
|
|
20
|
-
aria-label="is disabled textarea"
|
|
21
|
-
class="pf-c-form-control"
|
|
22
|
-
disabled=""
|
|
23
|
-
>
|
|
24
|
-
test textarea
|
|
25
|
-
</textarea>
|
|
26
|
-
</DocumentFragment>
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
exports[`TextArea horizontally resizable text area 1`] = `
|
|
30
|
-
<DocumentFragment>
|
|
31
|
-
<textarea
|
|
32
|
-
aria-invalid="true"
|
|
33
|
-
aria-label="horizontal resize textarea"
|
|
34
|
-
class="pf-c-form-control pf-m-resize-horizontal"
|
|
35
|
-
required=""
|
|
36
|
-
>
|
|
37
|
-
test textarea
|
|
38
|
-
</textarea>
|
|
39
|
-
</DocumentFragment>
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
exports[`TextArea read only text area using default readOnlyVariant 1`] = `
|
|
43
|
-
<DocumentFragment>
|
|
44
|
-
<textarea
|
|
45
|
-
aria-invalid="false"
|
|
46
|
-
aria-label="is default read only textarea"
|
|
47
|
-
class="pf-c-form-control"
|
|
48
|
-
readonly=""
|
|
49
|
-
>
|
|
50
|
-
test textarea
|
|
51
|
-
</textarea>
|
|
52
|
-
</DocumentFragment>
|
|
53
|
-
`;
|
|
54
|
-
|
|
55
|
-
exports[`TextArea read only text area using isReadOnly 1`] = `
|
|
56
|
-
<DocumentFragment>
|
|
57
|
-
<textarea
|
|
58
|
-
aria-invalid="false"
|
|
59
|
-
aria-label="is read only textarea"
|
|
60
|
-
class="pf-c-form-control"
|
|
61
|
-
readonly=""
|
|
62
|
-
>
|
|
63
|
-
test textarea
|
|
64
|
-
</textarea>
|
|
65
|
-
</DocumentFragment>
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
exports[`TextArea read only text area using plain readOnlyVariant 1`] = `
|
|
69
|
-
<DocumentFragment>
|
|
70
|
-
<textarea
|
|
71
|
-
aria-invalid="false"
|
|
72
|
-
aria-label="is plain read only textarea"
|
|
73
|
-
class="pf-c-form-control pf-m-plain"
|
|
74
|
-
readonly=""
|
|
75
|
-
>
|
|
76
|
-
test textarea
|
|
77
|
-
</textarea>
|
|
78
|
-
</DocumentFragment>
|
|
79
|
-
`;
|
|
80
|
-
|
|
81
|
-
exports[`TextArea read only text area using readOnly 1`] = `
|
|
82
|
-
<DocumentFragment>
|
|
83
|
-
<textarea
|
|
84
|
-
aria-invalid="false"
|
|
85
|
-
aria-label="read only textarea"
|
|
86
|
-
class="pf-c-form-control"
|
|
87
|
-
readonly=""
|
|
88
|
-
>
|
|
89
|
-
test textarea
|
|
90
|
-
</textarea>
|
|
91
|
-
</DocumentFragment>
|
|
92
|
-
`;
|
|
93
|
-
|
|
94
|
-
exports[`TextArea simple text area 1`] = `
|
|
95
|
-
<DocumentFragment>
|
|
96
|
-
<textarea
|
|
97
|
-
aria-invalid="false"
|
|
98
|
-
aria-label="simple textarea"
|
|
99
|
-
class="pf-c-form-control"
|
|
100
|
-
>
|
|
101
|
-
test textarea
|
|
102
|
-
</textarea>
|
|
103
|
-
</DocumentFragment>
|
|
104
|
-
`;
|
|
105
|
-
|
|
106
|
-
exports[`TextArea validated text area error 1`] = `
|
|
107
|
-
<DocumentFragment>
|
|
108
|
-
<textarea
|
|
109
|
-
aria-invalid="true"
|
|
110
|
-
aria-label="validated textarea"
|
|
111
|
-
class="pf-c-form-control"
|
|
112
10
|
required=""
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
</textarea>
|
|
116
|
-
</DocumentFragment>
|
|
117
|
-
`;
|
|
118
|
-
|
|
119
|
-
exports[`TextArea vertically resizable text area 1`] = `
|
|
120
|
-
<DocumentFragment>
|
|
121
|
-
<textarea
|
|
122
|
-
aria-invalid="false"
|
|
123
|
-
aria-label="vertical resize textarea"
|
|
124
|
-
class="pf-c-form-control pf-m-resize-vertical"
|
|
125
|
-
>
|
|
126
|
-
test textarea
|
|
127
|
-
</textarea>
|
|
11
|
+
style="--pf-c-form-control--textarea--Height: 6px;"
|
|
12
|
+
/>
|
|
128
13
|
</DocumentFragment>
|
|
129
14
|
`;
|