@patternfly/react-core 4.199.1 → 4.199.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 +24 -0
- package/package.json +5 -5
- package/src/components/AboutModal/__tests__/AboutModal.test.tsx +41 -60
- package/src/components/Accordion/__tests__/Accordion.test.tsx +23 -17
- package/src/components/Alert/__tests__/Alert.test.tsx +195 -184
- package/src/components/Alert/__tests__/Generated/AlertActionCloseButton.test.tsx +19 -17
- package/src/components/Alert/__tests__/Generated/__snapshots__/AlertActionCloseButton.test.tsx.snap +26 -4
- package/src/components/Alert/__tests__/__snapshots__/Alert.test.tsx.snap +50 -700
- package/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +68 -73
- package/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap +1 -893
- package/src/components/ApplicationLauncher/__tests__/Generated/ApplicationLauncherSeparator.test.tsx +13 -10
- package/src/components/ApplicationLauncher/__tests__/Generated/__snapshots__/ApplicationLauncherSeparator.test.tsx.snap +12 -1
- package/src/components/Button/__tests__/Button.test.tsx +116 -107
- package/src/components/Button/__tests__/__snapshots__/Button.test.tsx.snap +21 -21
- package/src/components/Card/__tests__/Card.test.tsx +119 -100
- package/src/components/Card/__tests__/CardBody.test.tsx +35 -28
- package/src/components/Card/__tests__/CardFooter.test.tsx +28 -24
- package/src/components/Card/__tests__/CardHeadMain.test.tsx +19 -14
- package/src/components/Card/__tests__/CardHeader.test.tsx +6 -22
- package/src/components/Card/__tests__/CardHeaderMain.test.tsx +19 -14
- package/src/components/Card/__tests__/CardTitle.test.tsx +25 -0
- package/src/components/Card/__tests__/__snapshots__/Card.test.tsx.snap +12 -28
- package/src/components/Card/__tests__/__snapshots__/CardBody.test.tsx.snap +2 -4
- package/src/components/Card/__tests__/__snapshots__/CardFooter.test.tsx.snap +1 -3
- package/src/components/Card/__tests__/__snapshots__/CardHeadMain.test.tsx.snap +1 -11
- package/src/components/Card/__tests__/__snapshots__/CardHeader.test.tsx.snap +1 -11
- package/src/components/Card/__tests__/__snapshots__/CardHeaderMain.test.tsx.snap +1 -11
- package/src/components/Card/__tests__/__snapshots__/CardTitle.test.tsx.snap +3 -0
- package/src/components/Checkbox/__tests__/Checkbox.test.tsx +66 -70
- package/src/components/Checkbox/__tests__/__snapshots__/Checkbox.test.tsx.snap +9 -204
- package/src/components/Chip/examples/Chip.md +1 -73
- package/src/components/Chip/examples/ChipDefault.tsx +68 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopy.md +11 -123
- package/src/components/ClipboardCopy/examples/ClipboardCopyBasic.tsx +8 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyExpanded.tsx +9 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyExpandedWithArray.tsx +14 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompact.tsx +7 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactCode.tsx +8 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactInSentence.tsx +36 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyInlineCompactWithAdditionalAction.tsx +20 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyJSONObject.tsx +18 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnly.tsx +8 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpanded.tsx +9 -0
- package/src/components/ClipboardCopy/examples/ClipboardCopyReadOnlyExpandedByDefault.tsx +9 -0
- package/src/layouts/Flex/examples/Flex.md +1 -1
|
@@ -1,86 +1,82 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import '@testing-library/jest-dom';
|
|
6
|
+
|
|
4
7
|
import { Checkbox } from '../Checkbox';
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
describe('Checkbox', () => {
|
|
10
|
+
test('controlled', () => {
|
|
11
|
+
render(<Checkbox isChecked id="check" aria-label="check" />);
|
|
12
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
13
|
+
});
|
|
10
14
|
|
|
11
|
-
test('controlled', () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
+
test('controlled - 3rd state', () => {
|
|
16
|
+
render(<Checkbox isChecked={null} id="check" aria-label="check" />);
|
|
17
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
18
|
+
});
|
|
15
19
|
|
|
16
|
-
test('
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
+
test('uncontrolled', () => {
|
|
21
|
+
render(<Checkbox id="check" aria-label="check" />);
|
|
22
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
23
|
+
});
|
|
20
24
|
|
|
21
|
-
test('
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
+
test('isDisabled', () => {
|
|
26
|
+
render(<Checkbox id="check" isDisabled aria-label="check" />);
|
|
27
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
28
|
+
});
|
|
25
29
|
|
|
26
|
-
test('
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
+
test('label is string', () => {
|
|
31
|
+
render(<Checkbox label="Label" id="check" isChecked aria-label="check" />);
|
|
32
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
33
|
+
});
|
|
30
34
|
|
|
31
|
-
test('label is
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
test('label is function', () => {
|
|
36
|
+
const functionLabel = () => <h1>Header</h1>;
|
|
37
|
+
render(<Checkbox label={functionLabel()} id="check" isChecked aria-label="check" />);
|
|
38
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
39
|
+
});
|
|
35
40
|
|
|
36
|
-
test('label is
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
+
test('label is node', () => {
|
|
42
|
+
render(<Checkbox label={<h1>Header</h1>} id="check" isChecked aria-label="check" />);
|
|
43
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
44
|
+
});
|
|
41
45
|
|
|
42
|
-
test('
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
+
test('passing class', () => {
|
|
47
|
+
render(<Checkbox label="label" className="class-123" id="check" isChecked aria-label="check" />);
|
|
48
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
49
|
+
});
|
|
46
50
|
|
|
47
|
-
test('passing
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
+
test('passing HTML attribute', () => {
|
|
52
|
+
render(<Checkbox label="label" aria-labelledby="labelId" id="check" isChecked aria-label="check" />);
|
|
53
|
+
expect(screen.getByRole('checkbox').outerHTML).toMatchSnapshot();
|
|
54
|
+
});
|
|
51
55
|
|
|
52
|
-
test('passing
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
+
test('passing description', () => {
|
|
57
|
+
render(<Checkbox id="check" label="checkbox" description="Text description..." />);
|
|
58
|
+
expect(screen.getByText('Text description...')).toBeInTheDocument();
|
|
59
|
+
});
|
|
56
60
|
|
|
57
|
-
test('passing
|
|
58
|
-
|
|
59
|
-
const descriptionEl = view.find('span[className="pf-c-check__description"]');
|
|
60
|
-
expect(descriptionEl.length).toBe(1);
|
|
61
|
-
expect(descriptionEl.text()).toBe('Text description...');
|
|
62
|
-
});
|
|
61
|
+
test('passing body', () => {
|
|
62
|
+
render(<Checkbox id="check" label="checkbox" body="This is where custom content goes." />);
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const bodyEl = view.find('span[className="pf-c-check__body"]');
|
|
67
|
-
expect(bodyEl.length).toBe(1);
|
|
68
|
-
expect(bodyEl.text()).toBe('This is where custom content goes.');
|
|
69
|
-
});
|
|
64
|
+
expect(screen.getByText('This is where custom content goes.')).toBeInTheDocument();
|
|
65
|
+
});
|
|
70
66
|
|
|
71
|
-
test('checkbox
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
67
|
+
test('checkbox onChange handler called when component is clicked', () => {
|
|
68
|
+
const onChangeHandler = jest.fn();
|
|
69
|
+
render(<Checkbox id="check" onChange={onChangeHandler} aria-label="check" isChecked={false} />);
|
|
70
|
+
|
|
71
|
+
userEvent.click(screen.getByLabelText('check'));
|
|
72
|
+
expect(onChangeHandler).toBeCalled();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('should throw console error when no id is given', () => {
|
|
76
|
+
const myMock = jest.fn();
|
|
77
|
+
global.console = { ...global.console, error: myMock };
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
render(<Checkbox {...props} />);
|
|
85
|
-
expect(myMock).toBeCalled();
|
|
79
|
+
render(<Checkbox id={undefined} />);
|
|
80
|
+
expect(myMock).toBeCalled();
|
|
81
|
+
});
|
|
86
82
|
});
|
|
@@ -1,214 +1,19 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`controlled - 3rd state 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<div
|
|
6
|
-
class="pf-c-check pf-m-standalone"
|
|
7
|
-
>
|
|
8
|
-
<input
|
|
9
|
-
aria-invalid="false"
|
|
10
|
-
aria-label="check"
|
|
11
|
-
class="pf-c-check__input"
|
|
12
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-2"
|
|
13
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
14
|
-
data-ouia-safe="true"
|
|
15
|
-
id="check"
|
|
16
|
-
type="checkbox"
|
|
17
|
-
/>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
`;
|
|
3
|
+
exports[`Checkbox controlled - 3rd state 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-2\\">"`;
|
|
21
4
|
|
|
22
|
-
exports[`controlled 1`] = `
|
|
23
|
-
<div>
|
|
24
|
-
<div
|
|
25
|
-
class="pf-c-check pf-m-standalone"
|
|
26
|
-
>
|
|
27
|
-
<input
|
|
28
|
-
aria-invalid="false"
|
|
29
|
-
aria-label="check"
|
|
30
|
-
checked=""
|
|
31
|
-
class="pf-c-check__input"
|
|
32
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-1"
|
|
33
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
34
|
-
data-ouia-safe="true"
|
|
35
|
-
id="check"
|
|
36
|
-
type="checkbox"
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
`;
|
|
5
|
+
exports[`Checkbox controlled 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-1\\" checked=\\"\\">"`;
|
|
41
6
|
|
|
42
|
-
exports[`isDisabled 1`] = `
|
|
43
|
-
<div>
|
|
44
|
-
<div
|
|
45
|
-
class="pf-c-check pf-m-standalone"
|
|
46
|
-
>
|
|
47
|
-
<input
|
|
48
|
-
aria-invalid="false"
|
|
49
|
-
aria-label="check"
|
|
50
|
-
class="pf-c-check__input"
|
|
51
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-4"
|
|
52
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
53
|
-
data-ouia-safe="true"
|
|
54
|
-
disabled=""
|
|
55
|
-
id="check"
|
|
56
|
-
type="checkbox"
|
|
57
|
-
/>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
`;
|
|
7
|
+
exports[`Checkbox isDisabled 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" disabled=\\"\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-4\\">"`;
|
|
61
8
|
|
|
62
|
-
exports[`label is function 1`] = `
|
|
63
|
-
<div>
|
|
64
|
-
<div
|
|
65
|
-
class="pf-c-check"
|
|
66
|
-
>
|
|
67
|
-
<input
|
|
68
|
-
aria-invalid="false"
|
|
69
|
-
aria-label="check"
|
|
70
|
-
checked=""
|
|
71
|
-
class="pf-c-check__input"
|
|
72
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-6"
|
|
73
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
74
|
-
data-ouia-safe="true"
|
|
75
|
-
id="check"
|
|
76
|
-
type="checkbox"
|
|
77
|
-
/>
|
|
78
|
-
<label
|
|
79
|
-
class="pf-c-check__label"
|
|
80
|
-
for="check"
|
|
81
|
-
>
|
|
82
|
-
<h1>
|
|
83
|
-
Header
|
|
84
|
-
</h1>
|
|
85
|
-
</label>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
`;
|
|
9
|
+
exports[`Checkbox label is function 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-6\\" checked=\\"\\">"`;
|
|
89
10
|
|
|
90
|
-
exports[`label is node 1`] = `
|
|
91
|
-
<div>
|
|
92
|
-
<div
|
|
93
|
-
class="pf-c-check"
|
|
94
|
-
>
|
|
95
|
-
<input
|
|
96
|
-
aria-invalid="false"
|
|
97
|
-
aria-label="check"
|
|
98
|
-
checked=""
|
|
99
|
-
class="pf-c-check__input"
|
|
100
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-7"
|
|
101
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
102
|
-
data-ouia-safe="true"
|
|
103
|
-
id="check"
|
|
104
|
-
type="checkbox"
|
|
105
|
-
/>
|
|
106
|
-
<label
|
|
107
|
-
class="pf-c-check__label"
|
|
108
|
-
for="check"
|
|
109
|
-
>
|
|
110
|
-
<h1>
|
|
111
|
-
Header
|
|
112
|
-
</h1>
|
|
113
|
-
</label>
|
|
114
|
-
</div>
|
|
115
|
-
</div>
|
|
116
|
-
`;
|
|
11
|
+
exports[`Checkbox label is node 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-7\\" checked=\\"\\">"`;
|
|
117
12
|
|
|
118
|
-
exports[`label is string 1`] = `
|
|
119
|
-
<div>
|
|
120
|
-
<div
|
|
121
|
-
class="pf-c-check"
|
|
122
|
-
>
|
|
123
|
-
<input
|
|
124
|
-
aria-invalid="false"
|
|
125
|
-
aria-label="check"
|
|
126
|
-
checked=""
|
|
127
|
-
class="pf-c-check__input"
|
|
128
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-5"
|
|
129
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
130
|
-
data-ouia-safe="true"
|
|
131
|
-
id="check"
|
|
132
|
-
type="checkbox"
|
|
133
|
-
/>
|
|
134
|
-
<label
|
|
135
|
-
class="pf-c-check__label"
|
|
136
|
-
for="check"
|
|
137
|
-
>
|
|
138
|
-
Label
|
|
139
|
-
</label>
|
|
140
|
-
</div>
|
|
141
|
-
</div>
|
|
142
|
-
`;
|
|
13
|
+
exports[`Checkbox label is string 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-5\\" checked=\\"\\">"`;
|
|
143
14
|
|
|
144
|
-
exports[`passing HTML attribute 1`] = `
|
|
145
|
-
<div>
|
|
146
|
-
<div
|
|
147
|
-
class="pf-c-check"
|
|
148
|
-
>
|
|
149
|
-
<input
|
|
150
|
-
aria-invalid="false"
|
|
151
|
-
aria-label="check"
|
|
152
|
-
aria-labelledby="labelId"
|
|
153
|
-
checked=""
|
|
154
|
-
class="pf-c-check__input"
|
|
155
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-9"
|
|
156
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
157
|
-
data-ouia-safe="true"
|
|
158
|
-
id="check"
|
|
159
|
-
type="checkbox"
|
|
160
|
-
/>
|
|
161
|
-
<label
|
|
162
|
-
class="pf-c-check__label"
|
|
163
|
-
for="check"
|
|
164
|
-
>
|
|
165
|
-
label
|
|
166
|
-
</label>
|
|
167
|
-
</div>
|
|
168
|
-
</div>
|
|
169
|
-
`;
|
|
15
|
+
exports[`Checkbox passing HTML attribute 1`] = `"<input aria-labelledby=\\"labelId\\" id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-9\\" checked=\\"\\">"`;
|
|
170
16
|
|
|
171
|
-
exports[`passing class 1`] = `
|
|
172
|
-
<div>
|
|
173
|
-
<div
|
|
174
|
-
class="pf-c-check class-123"
|
|
175
|
-
>
|
|
176
|
-
<input
|
|
177
|
-
aria-invalid="false"
|
|
178
|
-
aria-label="check"
|
|
179
|
-
checked=""
|
|
180
|
-
class="pf-c-check__input"
|
|
181
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-8"
|
|
182
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
183
|
-
data-ouia-safe="true"
|
|
184
|
-
id="check"
|
|
185
|
-
type="checkbox"
|
|
186
|
-
/>
|
|
187
|
-
<label
|
|
188
|
-
class="pf-c-check__label"
|
|
189
|
-
for="check"
|
|
190
|
-
>
|
|
191
|
-
label
|
|
192
|
-
</label>
|
|
193
|
-
</div>
|
|
194
|
-
</div>
|
|
195
|
-
`;
|
|
17
|
+
exports[`Checkbox passing class 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-8\\" checked=\\"\\">"`;
|
|
196
18
|
|
|
197
|
-
exports[`uncontrolled 1`] = `
|
|
198
|
-
<div>
|
|
199
|
-
<div
|
|
200
|
-
class="pf-c-check pf-m-standalone"
|
|
201
|
-
>
|
|
202
|
-
<input
|
|
203
|
-
aria-invalid="false"
|
|
204
|
-
aria-label="check"
|
|
205
|
-
class="pf-c-check__input"
|
|
206
|
-
data-ouia-component-id="OUIA-Generated-Checkbox-3"
|
|
207
|
-
data-ouia-component-type="PF4/Checkbox"
|
|
208
|
-
data-ouia-safe="true"
|
|
209
|
-
id="check"
|
|
210
|
-
type="checkbox"
|
|
211
|
-
/>
|
|
212
|
-
</div>
|
|
213
|
-
</div>
|
|
214
|
-
`;
|
|
19
|
+
exports[`Checkbox uncontrolled 1`] = `"<input id=\\"check\\" class=\\"pf-c-check__input\\" type=\\"checkbox\\" aria-invalid=\\"false\\" aria-label=\\"check\\" data-ouia-component-type=\\"PF4/Checkbox\\" data-ouia-safe=\\"true\\" data-ouia-component-id=\\"OUIA-Generated-Checkbox-3\\">"`;
|
|
@@ -10,77 +10,5 @@ ouia: true
|
|
|
10
10
|
|
|
11
11
|
### Default
|
|
12
12
|
|
|
13
|
-
```
|
|
14
|
-
import React from 'react';
|
|
15
|
-
import { Badge, Chip } from '@patternfly/react-core';
|
|
16
|
-
|
|
17
|
-
class SingleChip extends React.Component {
|
|
18
|
-
constructor(props) {
|
|
19
|
-
super(props);
|
|
20
|
-
this.state = {
|
|
21
|
-
chip: {
|
|
22
|
-
name: 'Chip 1'
|
|
23
|
-
},
|
|
24
|
-
longchip: {
|
|
25
|
-
name: 'Really long chip that goes on and on'
|
|
26
|
-
},
|
|
27
|
-
badgechip: {
|
|
28
|
-
name: 'Chip',
|
|
29
|
-
isRead: true,
|
|
30
|
-
count: 7
|
|
31
|
-
},
|
|
32
|
-
readonlychip: {
|
|
33
|
-
name: 'Read-only chip'
|
|
34
|
-
},
|
|
35
|
-
overflowchip: {
|
|
36
|
-
name: 'Overflow chip'
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
this.deleteItem = id => {
|
|
40
|
-
this.setState({ [id]: null });
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
render() {
|
|
45
|
-
const { chip, longchip, badgechip, readonlychip, overflowchip } = this.state;
|
|
46
|
-
return (
|
|
47
|
-
<React.Fragment>
|
|
48
|
-
{chip && (
|
|
49
|
-
<React.Fragment>
|
|
50
|
-
<Chip key="chip1" onClick={() => this.deleteItem('chip')}>
|
|
51
|
-
{chip.name}
|
|
52
|
-
</Chip>
|
|
53
|
-
<br /> <br />
|
|
54
|
-
</React.Fragment>
|
|
55
|
-
)}
|
|
56
|
-
{longchip && (
|
|
57
|
-
<React.Fragment>
|
|
58
|
-
<Chip key="chip2" onClick={() => this.deleteItem('longchip')}>
|
|
59
|
-
{longchip.name}
|
|
60
|
-
</Chip>
|
|
61
|
-
<br /> <br />
|
|
62
|
-
</React.Fragment>
|
|
63
|
-
)}
|
|
64
|
-
{badgechip && (
|
|
65
|
-
<React.Fragment>
|
|
66
|
-
<Chip key="chip3" onClick={() => this.deleteItem('badgechip')}>
|
|
67
|
-
{badgechip.name}
|
|
68
|
-
<Badge isRead={badgechip.isRead}>{badgechip.count}</Badge>
|
|
69
|
-
</Chip>
|
|
70
|
-
<br /> <br />
|
|
71
|
-
</React.Fragment>
|
|
72
|
-
)}
|
|
73
|
-
<Chip key="chip4" onClick={() => this.deleteItem('readonlychip')} isReadOnly>
|
|
74
|
-
{readonlychip.name}
|
|
75
|
-
</Chip>
|
|
76
|
-
<br /> <br />
|
|
77
|
-
{overflowchip && (
|
|
78
|
-
<Chip key="chip5" component="button" onClick={() => this.deleteItem('overflowchip')} isOverflowChip>
|
|
79
|
-
{overflowchip.name}
|
|
80
|
-
</Chip>
|
|
81
|
-
)}
|
|
82
|
-
</React.Fragment>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
13
|
+
```ts file='./ChipDefault.tsx'
|
|
86
14
|
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Badge, Chip } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ChipDefault: React.FunctionComponent = () => {
|
|
5
|
+
const [chips, setChips] = React.useState({
|
|
6
|
+
chip: {
|
|
7
|
+
name: 'Chip 1'
|
|
8
|
+
},
|
|
9
|
+
longchip: {
|
|
10
|
+
name: 'Really long chip that goes on and on'
|
|
11
|
+
},
|
|
12
|
+
badgechip: {
|
|
13
|
+
name: 'Chip',
|
|
14
|
+
isRead: true,
|
|
15
|
+
count: 7
|
|
16
|
+
},
|
|
17
|
+
readonlychip: {
|
|
18
|
+
name: 'Read-only chip'
|
|
19
|
+
},
|
|
20
|
+
overflowchip: {
|
|
21
|
+
name: 'Overflow chip'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const deleteItem = (id: string) => {
|
|
26
|
+
setChips({ ...chips, [id]: null });
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const { chip, longchip, badgechip, readonlychip, overflowchip } = chips;
|
|
30
|
+
return (
|
|
31
|
+
<React.Fragment>
|
|
32
|
+
{chip && (
|
|
33
|
+
<React.Fragment>
|
|
34
|
+
<Chip key="chip1" onClick={() => deleteItem('chip')}>
|
|
35
|
+
{chip.name}
|
|
36
|
+
</Chip>
|
|
37
|
+
<br /> <br />
|
|
38
|
+
</React.Fragment>
|
|
39
|
+
)}
|
|
40
|
+
{longchip && (
|
|
41
|
+
<React.Fragment>
|
|
42
|
+
<Chip key="chip2" onClick={() => deleteItem('longchip')}>
|
|
43
|
+
{longchip.name}
|
|
44
|
+
</Chip>
|
|
45
|
+
<br /> <br />
|
|
46
|
+
</React.Fragment>
|
|
47
|
+
)}
|
|
48
|
+
{badgechip && (
|
|
49
|
+
<React.Fragment>
|
|
50
|
+
<Chip key="chip3" onClick={() => deleteItem('badgechip')}>
|
|
51
|
+
{badgechip.name}
|
|
52
|
+
<Badge isRead={badgechip.isRead}>{badgechip.count}</Badge>
|
|
53
|
+
</Chip>
|
|
54
|
+
<br /> <br />
|
|
55
|
+
</React.Fragment>
|
|
56
|
+
)}
|
|
57
|
+
<Chip key="chip4" onClick={() => deleteItem('readonlychip')} isReadOnly>
|
|
58
|
+
{readonlychip.name}
|
|
59
|
+
</Chip>
|
|
60
|
+
<br /> <br />
|
|
61
|
+
{overflowchip && (
|
|
62
|
+
<Chip key="chip5" component="button" onClick={() => deleteItem('overflowchip')} isOverflowChip>
|
|
63
|
+
{overflowchip.name}
|
|
64
|
+
</Chip>
|
|
65
|
+
)}
|
|
66
|
+
</React.Fragment>
|
|
67
|
+
);
|
|
68
|
+
};
|