@patternfly/react-core 5.2.0-prerelease.29 → 5.2.0-prerelease.30
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/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/Chip/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/DragDrop/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/favorites/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/esm/components/Chip/Chip.d.ts +1 -0
- package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
- package/dist/esm/components/Chip/Chip.js +8 -0
- package/dist/esm/components/Chip/Chip.js.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts +5 -5
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.d.ts +0 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.d.ts.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopyExpanded.js.map +1 -1
- package/dist/esm/components/DataList/DataList.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataList.js +2 -2
- package/dist/esm/components/DataList/DataList.js.map +1 -1
- package/dist/esm/components/DataList/DataListAction.js +3 -3
- package/dist/esm/components/DataList/DataListAction.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/js/components/Chip/Chip.d.ts +1 -0
- package/dist/js/components/Chip/Chip.d.ts.map +1 -1
- package/dist/js/components/Chip/Chip.js +8 -0
- package/dist/js/components/Chip/Chip.js.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts +5 -5
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.d.ts +0 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.d.ts.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopyExpanded.js.map +1 -1
- package/dist/js/components/DataList/DataList.d.ts.map +1 -1
- package/dist/js/components/DataList/DataList.js +2 -2
- package/dist/js/components/DataList/DataList.js.map +1 -1
- package/dist/js/components/DataList/DataListAction.js +3 -3
- package/dist/js/components/DataList/DataListAction.js.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.js +1 -1
- package/dist/js/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +2 -2
- package/src/components/Chip/Chip.tsx +11 -0
- package/src/components/ClipboardCopy/ClipboardCopy.tsx +5 -5
- package/src/components/ClipboardCopy/ClipboardCopyExpanded.tsx +0 -1
- package/src/components/DataList/DataList.tsx +2 -0
- package/src/components/DataList/DataListAction.tsx +1 -1
- package/src/components/DataList/__tests__/DataList.test.tsx +140 -304
- package/src/components/DataList/__tests__/DataListAction.test.tsx +75 -0
- package/src/components/DataList/__tests__/DataListCell.test.tsx +120 -0
- package/src/components/DataList/__tests__/DataListCheck.test.tsx +5 -0
- package/src/components/DataList/__tests__/DataListContent.test.tsx +73 -0
- package/src/components/DataList/__tests__/DataListItem.test.tsx +46 -0
- package/src/components/DataList/__tests__/DataListItemCells.test.tsx +25 -0
- package/src/components/DataList/__tests__/DataListItemRow.test.tsx +44 -0
- package/src/components/DataList/__tests__/DataListToggle.test.tsx +61 -0
- package/src/components/DataList/__tests__/__snapshots__/DataList.test.tsx.snap +2 -323
- package/src/components/DataList/__tests__/__snapshots__/DataListAction.test.tsx.snap +11 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListCell.test.tsx.snap +11 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListContent.test.tsx.snap +17 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListItem.test.tsx.snap +11 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListItemCells.test.tsx.snap +9 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListItemRow.test.tsx.snap +9 -0
- package/src/components/DataList/__tests__/__snapshots__/DataListToggle.test.tsx.snap +45 -0
- package/src/components/DataList/examples/DataListCheckboxes.tsx +5 -5
- package/src/components/DataList/examples/DataListMixedExpandable.tsx +1 -1
- package/src/components/DatePicker/DatePicker.tsx +1 -1
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.test.tsx.snap +2 -2
- package/src/components/DescriptionList/__tests__/DescriptionList.test.tsx +128 -102
- package/src/components/DescriptionList/__tests__/DescriptionListDescription.test.tsx +25 -0
- package/src/components/DescriptionList/__tests__/DescriptionListGroup.test.tsx +25 -0
- package/src/components/DescriptionList/__tests__/DescriptionListHelpTextButton.test.tsx +27 -0
- package/src/components/DescriptionList/__tests__/DescriptionListTerm.test.tsx +35 -0
- package/src/components/DescriptionList/__tests__/DescriptionListTermHelpText.test.tsx +25 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionList.test.tsx.snap +1 -157
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListDescription.test.tsx.snap +15 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListGroup.test.tsx.snap +11 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListHelpTextButton.test.tsx.snap +14 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListTerm.test.tsx.snap +15 -0
- package/src/components/DescriptionList/__tests__/__snapshots__/DescriptionListTermHelpText.test.tsx.snap +11 -0
- package/src/components/HelperText/__tests__/HelperText.test.tsx +67 -57
- package/src/components/HelperText/__tests__/HelperTextItem.test.tsx +93 -0
- package/src/components/HelperText/__tests__/__snapshots__/HelperText.test.tsx.snap +2 -223
- package/src/components/HelperText/__tests__/__snapshots__/HelperTextItem.test.tsx.snap +15 -0
- package/src/demos/CustomMenus/CustomMenus.md +6 -0
- package/src/demos/CustomMenus/examples/InlineSearchFilterMenuDemo.tsx +102 -0
- package/src/demos/SearchInput/SearchInput.md +1 -1
|
@@ -1,66 +1,76 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { HelperText } from '../HelperText';
|
|
4
|
-
import { HelperTextItem } from '../HelperTextItem';
|
|
5
|
-
import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
test('simple helper text renders successfully', () => {
|
|
9
|
-
const { asFragment } = render(
|
|
10
|
-
<HelperText>
|
|
11
|
-
<HelperTextItem>help test text</HelperTextItem>
|
|
12
|
-
</HelperText>
|
|
13
|
-
);
|
|
14
|
-
expect(asFragment()).toMatchSnapshot();
|
|
15
|
-
});
|
|
5
|
+
import styles from '@patternfly/react-styles/css/components/HelperText/helper-text';
|
|
16
6
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
test('Renders to match snapshot', () => {
|
|
8
|
+
const { asFragment } = render(<HelperText />);
|
|
9
|
+
expect(asFragment()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('Renders without children', () => {
|
|
13
|
+
render(
|
|
14
|
+
<div data-testid="container">
|
|
15
|
+
<HelperText />
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(screen.getByTestId('container').firstChild).toBeVisible();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('Renders default classes', () => {
|
|
23
|
+
render(<HelperText>text</HelperText>);
|
|
24
|
+
expect(screen.getByText('text')).toHaveClass(styles.helperText);
|
|
25
|
+
});
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<HelperTextItem component="li">help test text 2</HelperTextItem>
|
|
33
|
-
</HelperText>
|
|
34
|
-
);
|
|
35
|
-
expect(asFragment()).toMatchSnapshot();
|
|
36
|
-
});
|
|
27
|
+
test('Renders id when id is passed', () => {
|
|
28
|
+
render(<HelperText id="helper-id">text </HelperText>);
|
|
29
|
+
expect(screen.getByText('text')).toHaveAttribute('id', 'helper-id');
|
|
30
|
+
});
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
test('Renders aria-live when isLiveRegion is passed', () => {
|
|
33
|
+
render(<HelperText isLiveRegion>text </HelperText>);
|
|
34
|
+
expect(screen.getByText('text')).toHaveAttribute('aria-live', 'polite');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('Does not render aria-live by default', () => {
|
|
38
|
+
render(<HelperText>text </HelperText>);
|
|
39
|
+
expect(screen.getByText('text')).not.toHaveAttribute('aria-live');
|
|
40
|
+
});
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
test('Spreads additional props when passed', () => {
|
|
43
|
+
render(<HelperText dir="rtl">text </HelperText>);
|
|
44
|
+
expect(screen.getByText('text')).toHaveAttribute('dir', 'rtl');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('Renders custom className', () => {
|
|
48
|
+
render(<HelperText className="custom">text </HelperText>);
|
|
49
|
+
expect(screen.getByText('text')).toHaveClass('custom');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('Renders with element passed to component prop', () => {
|
|
53
|
+
render(<HelperText component="ul">text</HelperText>);
|
|
54
|
+
expect(screen.getByText('text').tagName).toBe('UL');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('Renders with div by default when no component prop is passed', () => {
|
|
58
|
+
render(<HelperText>text</HelperText>);
|
|
59
|
+
expect(screen.getByText('text').tagName).toBe('DIV');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('Renders aria-label and role when component = ul', () => {
|
|
63
|
+
render(
|
|
64
|
+
<HelperText component="ul" aria-label="helper">
|
|
65
|
+
text
|
|
66
|
+
</HelperText>
|
|
67
|
+
);
|
|
68
|
+
expect(screen.getByText('text')).toHaveAttribute('aria-label', 'helper');
|
|
69
|
+
expect(screen.getByText('text')).toHaveAttribute('role', 'list');
|
|
70
|
+
});
|
|
55
71
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
<HelperTextItem>help test text 2</HelperTextItem>
|
|
61
|
-
<HelperTextItem>help test text 3</HelperTextItem>
|
|
62
|
-
</HelperText>
|
|
63
|
-
);
|
|
64
|
-
expect(asFragment()).toMatchSnapshot();
|
|
65
|
-
});
|
|
72
|
+
test('Does not render aria-label and role when component != ul', () => {
|
|
73
|
+
render(<HelperText aria-label="helper">text</HelperText>);
|
|
74
|
+
expect(screen.getByText('text')).not.toHaveAttribute('aria-label', 'helper');
|
|
75
|
+
expect(screen.getByText('text')).not.toHaveAttribute('role', 'list');
|
|
66
76
|
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { HelperTextItem } from '../HelperTextItem';
|
|
4
|
+
|
|
5
|
+
import styles from '@patternfly/react-styles/css/components/HelperText/helper-text';
|
|
6
|
+
|
|
7
|
+
test('Renders to match snapshot', () => {
|
|
8
|
+
const { asFragment } = render(<HelperTextItem>help test text</HelperTextItem>);
|
|
9
|
+
expect(asFragment()).toMatchSnapshot();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('Renders without children', () => {
|
|
13
|
+
render(
|
|
14
|
+
<div data-testid="container">
|
|
15
|
+
<HelperTextItem />
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(screen.getByTestId('container').firstChild).toBeVisible();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('Renders default classes', () => {
|
|
23
|
+
render(<HelperTextItem>help test text 1</HelperTextItem>);
|
|
24
|
+
expect(screen.getByText('help test text 1')).toHaveClass(styles.helperTextItemText);
|
|
25
|
+
expect(screen.getByText('help test text 1').parentElement).toHaveClass(styles.helperTextItem);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('Renders custom className', () => {
|
|
29
|
+
render(<HelperTextItem className="custom">help test text 1</HelperTextItem>);
|
|
30
|
+
expect(screen.getByText('help test text 1').parentElement).toHaveClass('custom');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Object.values(['indeterminate', 'warning', 'success', 'error']).forEach((variant) => {
|
|
34
|
+
test(`Renders with class ${styles.modifiers[variant]} when variant = ${variant}`, () => {
|
|
35
|
+
render(
|
|
36
|
+
<HelperTextItem variant={variant as 'default' | 'indeterminate' | 'warning' | 'success' | 'error'}>
|
|
37
|
+
text
|
|
38
|
+
</HelperTextItem>
|
|
39
|
+
);
|
|
40
|
+
expect(screen.getByText('text').parentElement).toHaveClass(styles.modifiers[variant]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('Renders id when id is passed', () => {
|
|
45
|
+
render(<HelperTextItem id="text-item">help test text 1</HelperTextItem>);
|
|
46
|
+
expect(screen.getByText('help test text 1').parentElement).toHaveAttribute('id', 'text-item');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('Renders as div by default when component is not passed', () => {
|
|
50
|
+
render(<HelperTextItem>help test text 1</HelperTextItem>);
|
|
51
|
+
expect(screen.getByText('help test text 1').parentElement?.tagName).toBe('DIV');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('Renders with element passed to component prop', () => {
|
|
55
|
+
render(<HelperTextItem component="li">help test text 1</HelperTextItem>);
|
|
56
|
+
expect(screen.getByText('help test text 1').parentElement?.tagName).toBe('LI');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('Renders custom icon', () => {
|
|
60
|
+
render(<HelperTextItem icon={<div>test</div>}>help test text</HelperTextItem>);
|
|
61
|
+
expect(screen.getByText('test').parentElement).toHaveClass(styles.helperTextItemIcon);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('Renders default icon when hasIcon = true and icon is not passed', () => {
|
|
65
|
+
render(<HelperTextItem hasIcon>help test text</HelperTextItem>);
|
|
66
|
+
expect(screen.getByText('help test text').parentElement?.querySelector('span')).toHaveClass(
|
|
67
|
+
styles.helperTextItemIcon
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('Renders custom icon when icon is passed and hasIcon = true', () => {
|
|
72
|
+
render(
|
|
73
|
+
<HelperTextItem hasIcon icon={<div>test</div>}>
|
|
74
|
+
help test text
|
|
75
|
+
</HelperTextItem>
|
|
76
|
+
);
|
|
77
|
+
expect(screen.getByText('test').parentElement).toHaveClass(styles.helperTextItemIcon);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('Renders dynamic helper text', () => {
|
|
81
|
+
render(<HelperTextItem isDynamic>help test text</HelperTextItem>);
|
|
82
|
+
expect(screen.getByText('help test text').parentElement).toHaveClass(styles.modifiers.dynamic);
|
|
83
|
+
expect(screen.getByText('help test text').querySelector('span')).toHaveClass('pf-v5-screen-reader');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('Renders custom screenreader text when isDynamic = true and screenReaderText is passed', () => {
|
|
87
|
+
render(
|
|
88
|
+
<HelperTextItem isDynamic screenReaderText="sr test">
|
|
89
|
+
help test text
|
|
90
|
+
</HelperTextItem>
|
|
91
|
+
);
|
|
92
|
+
expect(screen.getByText('help test text').querySelector('span')).toHaveTextContent('sr test');
|
|
93
|
+
});
|
|
@@ -1,230 +1,9 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`Renders to match snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="pf-v5-c-helper-text__item"
|
|
7
|
-
>
|
|
8
|
-
<span
|
|
9
|
-
class="pf-v5-c-helper-text__item-text"
|
|
10
|
-
>
|
|
11
|
-
default help test text
|
|
12
|
-
</span>
|
|
13
|
-
</div>
|
|
14
|
-
</DocumentFragment>
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
exports[`HelperText dynamic helper text renders successfully 1`] = `
|
|
18
|
-
<DocumentFragment>
|
|
19
|
-
<div
|
|
20
|
-
class="pf-v5-c-helper-text"
|
|
21
|
-
>
|
|
22
|
-
<div
|
|
23
|
-
class="pf-v5-c-helper-text__item pf-m-dynamic"
|
|
24
|
-
>
|
|
25
|
-
<span
|
|
26
|
-
aria-hidden="true"
|
|
27
|
-
class="pf-v5-c-helper-text__item-icon"
|
|
28
|
-
>
|
|
29
|
-
<svg
|
|
30
|
-
aria-hidden="true"
|
|
31
|
-
class="pf-v5-svg"
|
|
32
|
-
fill="currentColor"
|
|
33
|
-
height="1em"
|
|
34
|
-
role="img"
|
|
35
|
-
viewBox="0 0 448 512"
|
|
36
|
-
width="1em"
|
|
37
|
-
>
|
|
38
|
-
<path
|
|
39
|
-
d="M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"
|
|
40
|
-
/>
|
|
41
|
-
</svg>
|
|
42
|
-
</span>
|
|
43
|
-
<span
|
|
44
|
-
class="pf-v5-c-helper-text__item-text"
|
|
45
|
-
>
|
|
46
|
-
help test text
|
|
47
|
-
<span
|
|
48
|
-
class="pf-v5-screen-reader"
|
|
49
|
-
>
|
|
50
|
-
: default status;
|
|
51
|
-
</span>
|
|
52
|
-
</span>
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</DocumentFragment>
|
|
56
|
-
`;
|
|
57
|
-
|
|
58
|
-
exports[`HelperText helper text block renders successfully 1`] = `
|
|
59
|
-
<DocumentFragment>
|
|
60
|
-
<div
|
|
61
|
-
class="pf-v5-c-helper-text"
|
|
62
|
-
>
|
|
63
|
-
<div
|
|
64
|
-
class="pf-v5-c-helper-text__item"
|
|
65
|
-
>
|
|
66
|
-
<span
|
|
67
|
-
class="pf-v5-c-helper-text__item-text"
|
|
68
|
-
>
|
|
69
|
-
help test text 1
|
|
70
|
-
</span>
|
|
71
|
-
</div>
|
|
72
|
-
<div
|
|
73
|
-
class="pf-v5-c-helper-text__item"
|
|
74
|
-
>
|
|
75
|
-
<span
|
|
76
|
-
class="pf-v5-c-helper-text__item-text"
|
|
77
|
-
>
|
|
78
|
-
help test text 2
|
|
79
|
-
</span>
|
|
80
|
-
</div>
|
|
81
|
-
<div
|
|
82
|
-
class="pf-v5-c-helper-text__item"
|
|
83
|
-
>
|
|
84
|
-
<span
|
|
85
|
-
class="pf-v5-c-helper-text__item-text"
|
|
86
|
-
>
|
|
87
|
-
help test text 3
|
|
88
|
-
</span>
|
|
89
|
-
</div>
|
|
90
|
-
</div>
|
|
91
|
-
</DocumentFragment>
|
|
92
|
-
`;
|
|
93
|
-
|
|
94
|
-
exports[`HelperText icon helper text renders properly 1`] = `
|
|
95
|
-
<DocumentFragment>
|
|
96
|
-
<div
|
|
97
|
-
class="pf-v5-c-helper-text"
|
|
98
|
-
>
|
|
99
|
-
<div
|
|
100
|
-
class="pf-v5-c-helper-text__item"
|
|
101
|
-
>
|
|
102
|
-
<span
|
|
103
|
-
aria-hidden="true"
|
|
104
|
-
class="pf-v5-c-helper-text__item-icon"
|
|
105
|
-
>
|
|
106
|
-
<svg
|
|
107
|
-
aria-hidden="true"
|
|
108
|
-
class="pf-v5-svg"
|
|
109
|
-
fill="currentColor"
|
|
110
|
-
height="1em"
|
|
111
|
-
role="img"
|
|
112
|
-
viewBox="0 0 512 512"
|
|
113
|
-
width="1em"
|
|
114
|
-
>
|
|
115
|
-
<path
|
|
116
|
-
d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"
|
|
117
|
-
/>
|
|
118
|
-
</svg>
|
|
119
|
-
</span>
|
|
120
|
-
<span
|
|
121
|
-
class="pf-v5-c-helper-text__item-text"
|
|
122
|
-
>
|
|
123
|
-
help test text
|
|
124
|
-
</span>
|
|
125
|
-
</div>
|
|
126
|
-
</div>
|
|
127
|
-
</DocumentFragment>
|
|
128
|
-
`;
|
|
129
|
-
|
|
130
|
-
exports[`HelperText indeterminate helper text variant applies successfully 1`] = `
|
|
131
|
-
<DocumentFragment>
|
|
132
|
-
<div
|
|
133
|
-
class="pf-v5-c-helper-text__item pf-m-indeterminate"
|
|
134
|
-
>
|
|
135
|
-
<span
|
|
136
|
-
class="pf-v5-c-helper-text__item-text"
|
|
137
|
-
>
|
|
138
|
-
indeterminate help test text
|
|
139
|
-
</span>
|
|
140
|
-
</div>
|
|
141
|
-
</DocumentFragment>
|
|
142
|
-
`;
|
|
143
|
-
|
|
144
|
-
exports[`HelperText invalid helper text variant applies successfully 1`] = `
|
|
145
|
-
<DocumentFragment>
|
|
146
|
-
<div
|
|
147
|
-
class="pf-v5-c-helper-text__item"
|
|
148
|
-
>
|
|
149
|
-
<span
|
|
150
|
-
class="pf-v5-c-helper-text__item-text"
|
|
151
|
-
>
|
|
152
|
-
invalid help test text
|
|
153
|
-
</span>
|
|
154
|
-
</div>
|
|
155
|
-
</DocumentFragment>
|
|
156
|
-
`;
|
|
157
|
-
|
|
158
|
-
exports[`HelperText simple helper text renders successfully 1`] = `
|
|
159
|
-
<DocumentFragment>
|
|
160
|
-
<div
|
|
161
|
-
class="pf-v5-c-helper-text"
|
|
162
|
-
>
|
|
163
|
-
<div
|
|
164
|
-
class="pf-v5-c-helper-text__item"
|
|
165
|
-
>
|
|
166
|
-
<span
|
|
167
|
-
class="pf-v5-c-helper-text__item-text"
|
|
168
|
-
>
|
|
169
|
-
help test text
|
|
170
|
-
</span>
|
|
171
|
-
</div>
|
|
172
|
-
</div>
|
|
173
|
-
</DocumentFragment>
|
|
174
|
-
`;
|
|
175
|
-
|
|
176
|
-
exports[`HelperText success helper text variant applies successfully 1`] = `
|
|
177
|
-
<DocumentFragment>
|
|
178
|
-
<div
|
|
179
|
-
class="pf-v5-c-helper-text__item pf-m-success"
|
|
180
|
-
>
|
|
181
|
-
<span
|
|
182
|
-
class="pf-v5-c-helper-text__item-text"
|
|
183
|
-
>
|
|
184
|
-
success help test text
|
|
185
|
-
</span>
|
|
186
|
-
</div>
|
|
187
|
-
</DocumentFragment>
|
|
188
|
-
`;
|
|
189
|
-
|
|
190
|
-
exports[`HelperText variant comonent helper text renders properly 1`] = `
|
|
191
|
-
<DocumentFragment>
|
|
192
|
-
<ul
|
|
193
6
|
class="pf-v5-c-helper-text"
|
|
194
|
-
|
|
195
|
-
>
|
|
196
|
-
<li
|
|
197
|
-
class="pf-v5-c-helper-text__item"
|
|
198
|
-
>
|
|
199
|
-
<span
|
|
200
|
-
class="pf-v5-c-helper-text__item-text"
|
|
201
|
-
>
|
|
202
|
-
help test text 1
|
|
203
|
-
</span>
|
|
204
|
-
</li>
|
|
205
|
-
<li
|
|
206
|
-
class="pf-v5-c-helper-text__item"
|
|
207
|
-
>
|
|
208
|
-
<span
|
|
209
|
-
class="pf-v5-c-helper-text__item-text"
|
|
210
|
-
>
|
|
211
|
-
help test text 2
|
|
212
|
-
</span>
|
|
213
|
-
</li>
|
|
214
|
-
</ul>
|
|
215
|
-
</DocumentFragment>
|
|
216
|
-
`;
|
|
217
|
-
|
|
218
|
-
exports[`HelperText warning helper text variant applies successfully 1`] = `
|
|
219
|
-
<DocumentFragment>
|
|
220
|
-
<div
|
|
221
|
-
class="pf-v5-c-helper-text__item pf-m-warning"
|
|
222
|
-
>
|
|
223
|
-
<span
|
|
224
|
-
class="pf-v5-c-helper-text__item-text"
|
|
225
|
-
>
|
|
226
|
-
warning help test text
|
|
227
|
-
</span>
|
|
228
|
-
</div>
|
|
7
|
+
/>
|
|
229
8
|
</DocumentFragment>
|
|
230
9
|
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Renders to match snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="pf-v5-c-helper-text__item"
|
|
7
|
+
>
|
|
8
|
+
<span
|
|
9
|
+
class="pf-v5-c-helper-text__item-text"
|
|
10
|
+
>
|
|
11
|
+
help test text
|
|
12
|
+
</span>
|
|
13
|
+
</div>
|
|
14
|
+
</DocumentFragment>
|
|
15
|
+
`;
|
|
@@ -50,6 +50,12 @@ Additionally, menu components may be connected to each other manually through ou
|
|
|
50
50
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
### With inline search filter
|
|
54
|
+
|
|
55
|
+
```ts file="./examples/InlineSearchFilterMenuDemo.tsx"
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
53
59
|
### Tree view menu
|
|
54
60
|
|
|
55
61
|
When rendering a menu-like element that does not contain `<MenuItem>` components, [panel](/components/panel) allows more flexible control and customization.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Menu,
|
|
4
|
+
MenuList,
|
|
5
|
+
MenuContent,
|
|
6
|
+
MenuSearch,
|
|
7
|
+
MenuSearchInput,
|
|
8
|
+
Divider,
|
|
9
|
+
SearchInput,
|
|
10
|
+
SelectOption,
|
|
11
|
+
MenuToggle,
|
|
12
|
+
MenuContainer
|
|
13
|
+
} from '@patternfly/react-core';
|
|
14
|
+
|
|
15
|
+
export const InlineSearchFilterMenuDemo: React.FunctionComponent = () => {
|
|
16
|
+
const [activeItem, setActiveItem] = React.useState(0);
|
|
17
|
+
const [input, setInput] = React.useState('');
|
|
18
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
19
|
+
const toggleRef = React.useRef<any>();
|
|
20
|
+
const menuRef = React.useRef<any>();
|
|
21
|
+
|
|
22
|
+
const onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, itemId: number | string | undefined) => {
|
|
23
|
+
const item = itemId as number;
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.log(`clicked ${itemId}`);
|
|
26
|
+
setActiveItem(item);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const handleTextInputChange = (value: string) => {
|
|
30
|
+
if (!isOpen) {
|
|
31
|
+
setIsOpen(true);
|
|
32
|
+
}
|
|
33
|
+
setInput(value);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const menuListItemsText = [
|
|
37
|
+
'Action 1',
|
|
38
|
+
'Action 2',
|
|
39
|
+
'Action 3',
|
|
40
|
+
'My project',
|
|
41
|
+
'OpenShift cluster',
|
|
42
|
+
'Production Ansible',
|
|
43
|
+
'AWS',
|
|
44
|
+
'Azure',
|
|
45
|
+
'My project 2',
|
|
46
|
+
'OpenShift cluster ',
|
|
47
|
+
'Production Ansible 2 ',
|
|
48
|
+
'AWS 2',
|
|
49
|
+
'Azure 2'
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const menuListItems = menuListItemsText
|
|
53
|
+
.filter((item) => !input || item.toLowerCase().includes(input.toString().toLowerCase()))
|
|
54
|
+
.map((currentValue, index) => (
|
|
55
|
+
<SelectOption key={currentValue} itemId={index}>
|
|
56
|
+
{currentValue}
|
|
57
|
+
</SelectOption>
|
|
58
|
+
));
|
|
59
|
+
if (input && menuListItems.length === 0) {
|
|
60
|
+
menuListItems.push(
|
|
61
|
+
<SelectOption isDisabled key="no result">
|
|
62
|
+
No results found
|
|
63
|
+
</SelectOption>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const toggle = (
|
|
68
|
+
<MenuToggle ref={toggleRef} onClick={() => setIsOpen(!isOpen)} isExpanded={isOpen}>
|
|
69
|
+
{isOpen ? 'Expanded' : 'Collapsed'}
|
|
70
|
+
</MenuToggle>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const menu = (
|
|
74
|
+
<Menu ref={menuRef} onSelect={onSelect} activeItemId={activeItem} isScrollable>
|
|
75
|
+
<MenuSearch>
|
|
76
|
+
<MenuSearchInput>
|
|
77
|
+
<SearchInput
|
|
78
|
+
value={input}
|
|
79
|
+
aria-label="Filter menu items"
|
|
80
|
+
onChange={(_event, value) => handleTextInputChange(value)}
|
|
81
|
+
/>
|
|
82
|
+
</MenuSearchInput>
|
|
83
|
+
</MenuSearch>
|
|
84
|
+
<Divider />
|
|
85
|
+
<MenuContent maxMenuHeight="200px">
|
|
86
|
+
<MenuList>{menuListItems}</MenuList>
|
|
87
|
+
</MenuContent>
|
|
88
|
+
</Menu>
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<MenuContainer
|
|
93
|
+
menu={menu}
|
|
94
|
+
menuRef={menuRef}
|
|
95
|
+
toggle={toggle}
|
|
96
|
+
toggleRef={toggleRef}
|
|
97
|
+
isOpen={isOpen}
|
|
98
|
+
onOpenChange={(isOpen) => setIsOpen(isOpen)}
|
|
99
|
+
onOpenChangeKeys={['Escape']}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
@@ -492,7 +492,7 @@ AdvancedComposableSearchInput = () => {
|
|
|
492
492
|
id="datePicker"
|
|
493
493
|
style={{ width: '100%' }}
|
|
494
494
|
value={date}
|
|
495
|
-
onChange={setDate}
|
|
495
|
+
onChange={(_e, newValue) => setDate(newValue)}
|
|
496
496
|
appendTo={() => document.querySelector('#datePicker')}
|
|
497
497
|
/>
|
|
498
498
|
</FormGroup>
|