@patternfly/react-core 6.0.0-alpha.30 → 6.0.0-alpha.32
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 +12 -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/Modal/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/dynamic/styles/package.json +1 -1
- package/dist/esm/components/ActionList/ActionList.js +1 -1
- package/dist/esm/components/ActionList/ActionList.js.map +1 -1
- package/dist/esm/components/ActionList/ActionListGroup.d.ts +2 -0
- package/dist/esm/components/ActionList/ActionListGroup.d.ts.map +1 -1
- package/dist/esm/components/ActionList/ActionListGroup.js +2 -2
- package/dist/esm/components/ActionList/ActionListGroup.js.map +1 -1
- package/dist/esm/components/ActionList/ActionListItem.js +1 -1
- package/dist/esm/components/ActionList/ActionListItem.js.map +1 -1
- package/dist/esm/components/Card/Card.d.ts +2 -16
- package/dist/esm/components/Card/Card.d.ts.map +1 -1
- package/dist/esm/components/Card/Card.js +3 -45
- package/dist/esm/components/Card/Card.js.map +1 -1
- package/dist/esm/components/Card/CardHeader.d.ts.map +1 -1
- package/dist/esm/components/Card/CardHeader.js +2 -5
- package/dist/esm/components/Card/CardHeader.js.map +1 -1
- package/dist/esm/components/Card/CardTitle.d.ts.map +1 -1
- package/dist/esm/components/Card/CardTitle.js +1 -5
- package/dist/esm/components/Card/CardTitle.js.map +1 -1
- package/dist/js/components/ActionList/ActionList.js +1 -1
- package/dist/js/components/ActionList/ActionList.js.map +1 -1
- package/dist/js/components/ActionList/ActionListGroup.d.ts +2 -0
- package/dist/js/components/ActionList/ActionListGroup.d.ts.map +1 -1
- package/dist/js/components/ActionList/ActionListGroup.js +2 -2
- package/dist/js/components/ActionList/ActionListGroup.js.map +1 -1
- package/dist/js/components/ActionList/ActionListItem.js +1 -1
- package/dist/js/components/ActionList/ActionListItem.js.map +1 -1
- package/dist/js/components/Card/Card.d.ts +2 -16
- package/dist/js/components/Card/Card.d.ts.map +1 -1
- package/dist/js/components/Card/Card.js +3 -45
- package/dist/js/components/Card/Card.js.map +1 -1
- package/dist/js/components/Card/CardHeader.d.ts.map +1 -1
- package/dist/js/components/Card/CardHeader.js +2 -5
- package/dist/js/components/Card/CardHeader.js.map +1 -1
- package/dist/js/components/Card/CardTitle.d.ts.map +1 -1
- package/dist/js/components/Card/CardTitle.js +1 -5
- package/dist/js/components/Card/CardTitle.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/ActionList/ActionList.tsx +1 -1
- package/src/components/ActionList/ActionListGroup.tsx +5 -2
- package/src/components/ActionList/ActionListItem.tsx +1 -1
- package/src/components/ActionList/__tests__/ActionListGroup.test.tsx +8 -2
- package/src/components/ActionList/examples/ActionListSingleGroup.tsx +45 -40
- package/src/components/ActionList/examples/ActionListWithCancelButton.tsx +12 -10
- package/src/components/ActionList/examples/ActionListWithIcons.tsx +44 -13
- package/src/components/Card/Card.tsx +6 -82
- package/src/components/Card/CardHeader.tsx +2 -6
- package/src/components/Card/CardTitle.tsx +1 -7
- package/src/components/Card/__tests__/Card.test.tsx +5 -123
- package/src/components/Card/__tests__/CardTitle.test.tsx +0 -13
- package/src/components/Card/examples/Card.md +17 -34
- package/src/components/Card/examples/CardClickable.tsx +62 -44
- package/src/components/Card/examples/CardClickableSelectable.tsx +93 -59
- package/src/components/Card/examples/CardExpandableWithIcon.tsx +1 -1
- package/src/components/Card/examples/CardSecondary.tsx +10 -0
- package/src/components/Card/examples/CardSelectable.tsx +62 -45
- package/src/components/Card/examples/CardSingleSelectable.tsx +3 -3
- package/src/components/Card/examples/CardWithDividers.tsx +14 -0
- package/src/components/Card/examples/CardWithImageAndActions.tsx +18 -18
- package/src/components/Card/examples/CardWithModifiers.tsx +0 -1
- package/src/demos/examples/Card/CardHorizontalSplit.tsx +1 -1
- package/src/demos/examples/Tabs/NestedUnindentedTabs.tsx +3 -3
- package/src/components/Card/examples/CardDeprecatedSelectable.tsx +0 -127
- package/src/components/Card/examples/CardDeprecatedSelectableA11yHighlight.tsx +0 -61
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.0.0-alpha.31","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.0.0-alpha.31","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.0.0-alpha.31","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.32",
|
|
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",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react": "^17 || ^18",
|
|
74
74
|
"react-dom": "^17 || ^18"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "c496543a1dc5cbdfdee8b12841e603f7eac7bf01"
|
|
77
77
|
}
|
|
@@ -14,7 +14,7 @@ export interface ActionListProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
14
14
|
export const ActionList: React.FunctionComponent<ActionListProps> = ({
|
|
15
15
|
children,
|
|
16
16
|
isIconList,
|
|
17
|
-
className
|
|
17
|
+
className,
|
|
18
18
|
...props
|
|
19
19
|
}: ActionListProps) => (
|
|
20
20
|
<div className={css(styles.actionList, isIconList && styles.modifiers.icons, className)} {...props}>
|
|
@@ -7,14 +7,17 @@ export interface ActionListGroupProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
/** Additional classes added to the action list group */
|
|
9
9
|
className?: string;
|
|
10
|
+
/** Flag indicating the action list group contains multiple icons and item padding should be removed */
|
|
11
|
+
isIconGroup?: boolean;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export const ActionListGroup: React.FunctionComponent<ActionListGroupProps> = ({
|
|
13
15
|
children,
|
|
14
|
-
className
|
|
16
|
+
className,
|
|
17
|
+
isIconGroup,
|
|
15
18
|
...props
|
|
16
19
|
}: ActionListGroupProps) => (
|
|
17
|
-
<div className={css(styles.actionListGroup, className)} {...props}>
|
|
20
|
+
<div className={css(styles.actionListGroup, isIconGroup && styles.modifiers.icons, className)} {...props}>
|
|
18
21
|
{children}
|
|
19
22
|
</div>
|
|
20
23
|
);
|
|
@@ -11,7 +11,7 @@ export interface ActionListItemProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
11
11
|
|
|
12
12
|
export const ActionListItem: React.FunctionComponent<ActionListItemProps> = ({
|
|
13
13
|
children,
|
|
14
|
-
className
|
|
14
|
+
className,
|
|
15
15
|
...props
|
|
16
16
|
}: ActionListItemProps) => (
|
|
17
17
|
<div className={css(`${styles.actionList}__item`, className)} {...props}>
|
|
@@ -14,10 +14,16 @@ test('Renders children', () => {
|
|
|
14
14
|
expect(screen.getByText('Test')).toBeVisible();
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
test(`Renders with class ${styles.actionListGroup}`, () => {
|
|
17
|
+
test(`Renders with only class ${styles.actionListGroup} by default`, () => {
|
|
18
18
|
render(<ActionListGroup>Test</ActionListGroup>);
|
|
19
19
|
|
|
20
|
-
expect(screen.getByText('Test')).toHaveClass(styles.actionListGroup);
|
|
20
|
+
expect(screen.getByText('Test')).toHaveClass(styles.actionListGroup, { exact: true });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test(`Renders with class ${styles.modifiers.icons} when isIconGroup is true`, () => {
|
|
24
|
+
render(<ActionListGroup isIconGroup>Test</ActionListGroup>);
|
|
25
|
+
|
|
26
|
+
expect(screen.getByText('Test')).toHaveClass(styles.modifiers.icons);
|
|
21
27
|
});
|
|
22
28
|
|
|
23
29
|
test('Renders with custom class names provided via prop', () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ActionList,
|
|
4
|
+
ActionListGroup,
|
|
4
5
|
ActionListItem,
|
|
5
6
|
Button,
|
|
6
7
|
Dropdown,
|
|
@@ -46,50 +47,54 @@ export const ActionListSingleGroup: React.FunctionComponent = () => {
|
|
|
46
47
|
return (
|
|
47
48
|
<React.Fragment>
|
|
48
49
|
<ActionList>
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
<ActionListGroup>
|
|
51
|
+
<ActionListItem>
|
|
52
|
+
<Button variant="primary" id="single-group-next-button">
|
|
53
|
+
Next
|
|
54
|
+
</Button>
|
|
55
|
+
</ActionListItem>
|
|
56
|
+
<ActionListItem>
|
|
57
|
+
<Button variant="secondary" id="single-group-back-button">
|
|
58
|
+
Back
|
|
59
|
+
</Button>
|
|
60
|
+
</ActionListItem>
|
|
61
|
+
</ActionListGroup>
|
|
59
62
|
</ActionList>
|
|
60
63
|
<br />
|
|
61
64
|
With kebab
|
|
62
65
|
<ActionList>
|
|
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
|
-
|
|
66
|
+
<ActionListGroup>
|
|
67
|
+
<ActionListItem>
|
|
68
|
+
<Button variant="primary" id="single-group-next-button2">
|
|
69
|
+
Next
|
|
70
|
+
</Button>
|
|
71
|
+
</ActionListItem>
|
|
72
|
+
<ActionListItem>
|
|
73
|
+
<Button variant="secondary" id="single-group-back-button2">
|
|
74
|
+
Back
|
|
75
|
+
</Button>
|
|
76
|
+
</ActionListItem>
|
|
77
|
+
<ActionListItem>
|
|
78
|
+
<Dropdown
|
|
79
|
+
onSelect={onSelect}
|
|
80
|
+
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
|
81
|
+
<MenuToggle
|
|
82
|
+
ref={toggleRef}
|
|
83
|
+
onClick={onToggle}
|
|
84
|
+
variant="plain"
|
|
85
|
+
isExpanded={isOpen}
|
|
86
|
+
aria-label="Action list single group kebab"
|
|
87
|
+
>
|
|
88
|
+
<EllipsisVIcon />
|
|
89
|
+
</MenuToggle>
|
|
90
|
+
)}
|
|
91
|
+
isOpen={isOpen}
|
|
92
|
+
onOpenChange={(isOpen: boolean) => setIsOpen(isOpen)}
|
|
93
|
+
>
|
|
94
|
+
<DropdownList>{dropdownItems}</DropdownList>
|
|
95
|
+
</Dropdown>
|
|
96
|
+
</ActionListItem>
|
|
97
|
+
</ActionListGroup>
|
|
93
98
|
</ActionList>
|
|
94
99
|
</React.Fragment>
|
|
95
100
|
);
|
|
@@ -5,16 +5,18 @@ export const ActionListWithCancelButton: React.FunctionComponent = () => (
|
|
|
5
5
|
<React.Fragment>
|
|
6
6
|
In modals, forms, data lists
|
|
7
7
|
<ActionList>
|
|
8
|
-
<
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
<ActionListGroup>
|
|
9
|
+
<ActionListItem>
|
|
10
|
+
<Button variant="primary" id="with-cancel-save-button">
|
|
11
|
+
Save
|
|
12
|
+
</Button>
|
|
13
|
+
</ActionListItem>
|
|
14
|
+
<ActionListItem>
|
|
15
|
+
<Button variant="link" id="with-cancel-cancel-button">
|
|
16
|
+
Cancel
|
|
17
|
+
</Button>
|
|
18
|
+
</ActionListItem>
|
|
19
|
+
</ActionListGroup>
|
|
18
20
|
</ActionList>
|
|
19
21
|
<br />
|
|
20
22
|
In wizards
|
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ActionList, ActionListItem, Button } from '@patternfly/react-core';
|
|
2
|
+
import { ActionList, ActionListGroup, ActionListItem, Button } from '@patternfly/react-core';
|
|
3
3
|
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
4
4
|
import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';
|
|
5
5
|
|
|
6
6
|
export const ActionListWithIcons: React.FunctionComponent = () => (
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
<>
|
|
8
|
+
<h4>With list icons wrapper</h4>
|
|
9
|
+
<ActionList isIconList>
|
|
10
|
+
<ActionListItem>
|
|
11
|
+
<Button variant="plain" id="with-icons-times-button" aria-label="times icon button">
|
|
12
|
+
<TimesIcon />
|
|
13
|
+
</Button>
|
|
14
|
+
</ActionListItem>
|
|
15
|
+
<ActionListItem>
|
|
16
|
+
<Button variant="plain" id="with-icons-check-button" aria-label="check icon button">
|
|
17
|
+
<CheckIcon />
|
|
18
|
+
</Button>
|
|
19
|
+
</ActionListItem>
|
|
20
|
+
</ActionList>
|
|
21
|
+
<br />
|
|
22
|
+
<h4>With group icons wrapper</h4>
|
|
23
|
+
<ActionList>
|
|
24
|
+
<ActionListGroup isIconGroup>
|
|
25
|
+
<ActionListItem>
|
|
26
|
+
<Button variant="plain" id="with-icons-list-times-button" aria-label="times icon button">
|
|
27
|
+
<TimesIcon />
|
|
28
|
+
</Button>
|
|
29
|
+
</ActionListItem>
|
|
30
|
+
<ActionListItem>
|
|
31
|
+
<Button variant="plain" id="with-icons-list-check-button" aria-label="check icon button">
|
|
32
|
+
<CheckIcon />
|
|
33
|
+
</Button>
|
|
34
|
+
</ActionListItem>
|
|
35
|
+
</ActionListGroup>
|
|
36
|
+
<ActionListGroup isIconGroup>
|
|
37
|
+
<ActionListItem>
|
|
38
|
+
<Button variant="plain" id="with-icons-group-times-button" aria-label="times icon button">
|
|
39
|
+
<TimesIcon />
|
|
40
|
+
</Button>
|
|
41
|
+
</ActionListItem>
|
|
42
|
+
<ActionListItem>
|
|
43
|
+
<Button variant="plain" id="with-icons-group-check-button" aria-label="check icon button">
|
|
44
|
+
<CheckIcon />
|
|
45
|
+
</Button>
|
|
46
|
+
</ActionListItem>
|
|
47
|
+
</ActionListGroup>
|
|
48
|
+
</ActionList>
|
|
49
|
+
</>
|
|
19
50
|
);
|
|
@@ -16,20 +16,12 @@ export interface CardProps extends React.HTMLProps<HTMLElement>, OUIAProps {
|
|
|
16
16
|
isCompact?: boolean;
|
|
17
17
|
/** Modifies the card to include selectable styling */
|
|
18
18
|
isSelectable?: boolean;
|
|
19
|
-
/** @deprecated Specifies the card is selectable, and applies raised styling on hover and select */
|
|
20
|
-
isSelectableRaised?: boolean;
|
|
21
19
|
/** Modifies the card to include selected styling */
|
|
22
20
|
isSelected?: boolean;
|
|
23
21
|
/** Modifies the card to include clickable styling */
|
|
24
22
|
isClickable?: boolean;
|
|
25
23
|
/** Modifies a clickable or selectable card to have disabled styling. */
|
|
26
24
|
isDisabled?: boolean;
|
|
27
|
-
/** @deprecated Modifies a raised selectable card to have disabled styling */
|
|
28
|
-
isDisabledRaised?: boolean;
|
|
29
|
-
/** Modifies the card to include flat styling */
|
|
30
|
-
isFlat?: boolean;
|
|
31
|
-
/** Modifies the card to include rounded styling */
|
|
32
|
-
isRounded?: boolean;
|
|
33
25
|
/** Modifies the card to be large. Should not be used with isCompact. */
|
|
34
26
|
isLarge?: boolean;
|
|
35
27
|
/** Cause component to consume the available height of its container */
|
|
@@ -38,12 +30,8 @@ export interface CardProps extends React.HTMLProps<HTMLElement>, OUIAProps {
|
|
|
38
30
|
isPlain?: boolean;
|
|
39
31
|
/** Flag indicating if a card is expanded. Modifies the card to be expandable. */
|
|
40
32
|
isExpanded?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
/** @deprecated Aria label to apply to the selectable input if one is rendered */
|
|
44
|
-
selectableInputAriaLabel?: string;
|
|
45
|
-
/** @deprecated Callback that executes when the selectable input is changed */
|
|
46
|
-
onSelectableInputChange?: (event: React.FormEvent<HTMLInputElement>, labelledBy: string) => void;
|
|
33
|
+
/** Card background color variant */
|
|
34
|
+
variant?: 'default' | 'secondary';
|
|
47
35
|
/** Value to overwrite the randomly generated data-ouia-component-id.*/
|
|
48
36
|
ouiaId?: number | string;
|
|
49
37
|
/** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
|
|
@@ -52,23 +40,14 @@ export interface CardProps extends React.HTMLProps<HTMLElement>, OUIAProps {
|
|
|
52
40
|
|
|
53
41
|
interface CardContextProps {
|
|
54
42
|
cardId: string;
|
|
55
|
-
registerTitleId: (id: string) => void;
|
|
56
43
|
isExpanded: boolean;
|
|
57
44
|
isClickable: boolean;
|
|
58
45
|
isSelectable: boolean;
|
|
59
46
|
isDisabled: boolean;
|
|
60
|
-
// TODO: Remove hasSelectableInput when deprecated prop is removed
|
|
61
|
-
hasSelectableInput: boolean;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
interface AriaProps {
|
|
65
|
-
'aria-label'?: string;
|
|
66
|
-
'aria-labelledby'?: string;
|
|
67
47
|
}
|
|
68
48
|
|
|
69
49
|
export const CardContext = React.createContext<Partial<CardContextProps>>({
|
|
70
50
|
cardId: '',
|
|
71
|
-
registerTitleId: () => {},
|
|
72
51
|
isExpanded: false,
|
|
73
52
|
isClickable: false,
|
|
74
53
|
isSelectable: false,
|
|
@@ -84,28 +63,19 @@ export const Card: React.FunctionComponent<CardProps> = ({
|
|
|
84
63
|
isSelectable = false,
|
|
85
64
|
isClickable = false,
|
|
86
65
|
isDisabled = false,
|
|
87
|
-
isSelectableRaised = false,
|
|
88
66
|
isSelected = false,
|
|
89
|
-
isDisabledRaised = false,
|
|
90
|
-
// TODO: Update with issue #9991
|
|
91
|
-
// isFlat = false,
|
|
92
67
|
isExpanded = false,
|
|
93
|
-
// TODO: Update with issue #9991
|
|
94
|
-
// isRounded = false,
|
|
95
68
|
isLarge = false,
|
|
96
69
|
isFullHeight = false,
|
|
97
70
|
isPlain = false,
|
|
71
|
+
variant = 'default',
|
|
98
72
|
ouiaId,
|
|
99
73
|
ouiaSafe = true,
|
|
100
|
-
|
|
101
|
-
selectableInputAriaLabel,
|
|
102
|
-
onSelectableInputChange = () => {},
|
|
74
|
+
|
|
103
75
|
...props
|
|
104
76
|
}: CardProps) => {
|
|
105
77
|
const Component = component as any;
|
|
106
78
|
const ouiaProps = useOUIAProps(Card.displayName, ouiaId, ouiaSafe);
|
|
107
|
-
const [titleId, setTitleId] = React.useState('');
|
|
108
|
-
const [ariaProps, setAriaProps] = React.useState<AriaProps>();
|
|
109
79
|
|
|
110
80
|
if (isCompact && isLarge) {
|
|
111
81
|
// eslint-disable-next-line no-console
|
|
@@ -114,13 +84,6 @@ export const Card: React.FunctionComponent<CardProps> = ({
|
|
|
114
84
|
}
|
|
115
85
|
|
|
116
86
|
const getSelectableModifiers = () => {
|
|
117
|
-
// TODO: Update with issue #9991
|
|
118
|
-
// if (isDisabledRaised) {
|
|
119
|
-
// return css(styles.modifiers.nonSelectableRaised);
|
|
120
|
-
// }
|
|
121
|
-
// if (isSelectableRaised) {
|
|
122
|
-
// return css(styles.modifiers.selectableRaised, isSelected && styles.modifiers.selectedRaised);
|
|
123
|
-
// }
|
|
124
87
|
if (isSelectable && isClickable) {
|
|
125
88
|
return css(styles.modifiers.selectable, styles.modifiers.clickable, isSelected && styles.modifiers.current);
|
|
126
89
|
}
|
|
@@ -136,69 +99,30 @@ export const Card: React.FunctionComponent<CardProps> = ({
|
|
|
136
99
|
return '';
|
|
137
100
|
};
|
|
138
101
|
|
|
139
|
-
const containsCardTitleChildRef = React.useRef(false);
|
|
140
|
-
|
|
141
|
-
const registerTitleId = (id: string) => {
|
|
142
|
-
setTitleId(id);
|
|
143
|
-
containsCardTitleChildRef.current = !!id;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
React.useEffect(() => {
|
|
147
|
-
if (selectableInputAriaLabel) {
|
|
148
|
-
setAriaProps({ 'aria-label': selectableInputAriaLabel });
|
|
149
|
-
} else if (titleId) {
|
|
150
|
-
setAriaProps({ 'aria-labelledby': titleId });
|
|
151
|
-
} else if (hasSelectableInput && !containsCardTitleChildRef.current) {
|
|
152
|
-
setAriaProps({});
|
|
153
|
-
// eslint-disable-next-line no-console
|
|
154
|
-
console.warn(
|
|
155
|
-
'If no CardTitle component is passed as a child of Card the selectableInputAriaLabel prop must be passed'
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
}, [hasSelectableInput, selectableInputAriaLabel, titleId]);
|
|
159
|
-
|
|
160
102
|
return (
|
|
161
103
|
<CardContext.Provider
|
|
162
104
|
value={{
|
|
163
105
|
cardId: id,
|
|
164
|
-
registerTitleId,
|
|
165
106
|
isExpanded,
|
|
166
107
|
isClickable,
|
|
167
108
|
isSelectable,
|
|
168
|
-
isDisabled
|
|
169
|
-
// TODO: Remove hasSelectableInput when deprecated prop is removed
|
|
170
|
-
hasSelectableInput
|
|
109
|
+
isDisabled
|
|
171
110
|
}}
|
|
172
111
|
>
|
|
173
|
-
{hasSelectableInput && (
|
|
174
|
-
<input
|
|
175
|
-
className="pf-v5-screen-reader"
|
|
176
|
-
id={`${id}-input`}
|
|
177
|
-
{...ariaProps}
|
|
178
|
-
type="checkbox"
|
|
179
|
-
checked={isSelected}
|
|
180
|
-
onChange={(event) => onSelectableInputChange(event, id)}
|
|
181
|
-
disabled={isDisabledRaised}
|
|
182
|
-
tabIndex={-1}
|
|
183
|
-
/>
|
|
184
|
-
)}
|
|
185
112
|
<Component
|
|
186
113
|
id={id}
|
|
187
114
|
className={css(
|
|
188
115
|
styles.card,
|
|
189
116
|
isCompact && styles.modifiers.compact,
|
|
190
117
|
isExpanded && styles.modifiers.expanded,
|
|
191
|
-
// TODO: Update with issue #9991
|
|
192
|
-
// isFlat && styles.modifiers.flat,
|
|
193
|
-
// isRounded && styles.modifiers.rounded,
|
|
194
118
|
isLarge && styles.modifiers.displayLg,
|
|
195
119
|
isFullHeight && styles.modifiers.fullHeight,
|
|
196
120
|
isPlain && styles.modifiers.plain,
|
|
121
|
+
variant === 'secondary' && styles.modifiers.secondary,
|
|
197
122
|
getSelectableModifiers(),
|
|
198
123
|
isDisabled && styles.modifiers.disabled,
|
|
199
124
|
className
|
|
200
125
|
)}
|
|
201
|
-
tabIndex={isSelectableRaised ? '0' : undefined}
|
|
202
126
|
{...props}
|
|
203
127
|
{...ouiaProps}
|
|
204
128
|
>
|
|
@@ -79,8 +79,7 @@ export const CardHeader: React.FunctionComponent<CardHeaderProps> = ({
|
|
|
79
79
|
...props
|
|
80
80
|
}: CardHeaderProps) => (
|
|
81
81
|
<CardContext.Consumer>
|
|
82
|
-
{
|
|
83
|
-
{({ cardId, isClickable, isSelectable, isDisabled: isCardDisabled, hasSelectableInput }) => {
|
|
82
|
+
{({ cardId, isClickable, isSelectable, isDisabled: isCardDisabled }) => {
|
|
84
83
|
const cardHeaderToggle = (
|
|
85
84
|
<div className={css(styles.cardHeaderToggle)}>
|
|
86
85
|
<Button
|
|
@@ -99,10 +98,7 @@ export const CardHeader: React.FunctionComponent<CardHeaderProps> = ({
|
|
|
99
98
|
);
|
|
100
99
|
|
|
101
100
|
const isClickableOrSelectableOnly = (isClickable && !isSelectable) || (isSelectable && !isClickable);
|
|
102
|
-
|
|
103
|
-
// We don't want to throw a warning for the deprecated card
|
|
104
|
-
const isDeprecatedSelectableCard = hasSelectableInput;
|
|
105
|
-
if (actions?.actions && isClickableOrSelectableOnly && !isDeprecatedSelectableCard) {
|
|
101
|
+
if (actions?.actions && isClickableOrSelectableOnly) {
|
|
106
102
|
// eslint-disable-next-line no-console
|
|
107
103
|
console.warn(
|
|
108
104
|
`${
|
|
@@ -18,16 +18,10 @@ export const CardTitle: React.FunctionComponent<CardTitleProps> = ({
|
|
|
18
18
|
component = 'div',
|
|
19
19
|
...props
|
|
20
20
|
}: CardTitleProps) => {
|
|
21
|
-
const { cardId
|
|
21
|
+
const { cardId } = React.useContext(CardContext);
|
|
22
22
|
const Component = component as any;
|
|
23
23
|
const titleId = cardId ? `${cardId}-title` : '';
|
|
24
24
|
|
|
25
|
-
React.useEffect(() => {
|
|
26
|
-
registerTitleId(titleId);
|
|
27
|
-
|
|
28
|
-
return () => registerTitleId('');
|
|
29
|
-
}, [registerTitleId, titleId]);
|
|
30
|
-
|
|
31
25
|
return (
|
|
32
26
|
<div className={css(styles.cardTitle)}>
|
|
33
27
|
<Component className={css(styles.cardTitleText, className)} id={titleId || undefined} {...props}>
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { render, screen } from '@testing-library/react';
|
|
4
4
|
import '@testing-library/jest-dom';
|
|
5
5
|
|
|
6
|
-
import { Card
|
|
6
|
+
import { Card } from '../Card';
|
|
7
7
|
|
|
8
8
|
describe('Card', () => {
|
|
9
9
|
test('renders with PatternFly Core styles', () => {
|
|
@@ -69,52 +69,11 @@ describe('Card', () => {
|
|
|
69
69
|
expect(card.getAttribute('tabindex')).toBeNull();
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
// TODO: Update with issue #9991
|
|
73
|
-
xtest('card with isDisabledRaised applied', () => {
|
|
74
|
-
render(<Card isDisabledRaised>disabled raised card</Card>);
|
|
75
|
-
expect(screen.getByText('disabled raised card')).toHaveClass('pf-m-non-selectable-raised');
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// TODO: Update with issue #9991
|
|
79
|
-
xtest('card with isSelectableRaised applied - not change', () => {
|
|
80
|
-
render(<Card isSelectableRaised>raised selectable card</Card>);
|
|
81
|
-
|
|
82
|
-
const card = screen.getByText('raised selectable card');
|
|
83
|
-
expect(card).toHaveClass('pf-m-selectable-raised');
|
|
84
|
-
expect(card).toHaveAttribute('tabindex', '0');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// TODO: Update with issue #9991
|
|
88
|
-
xtest('card with isSelectableRaised and isSelected applied ', () => {
|
|
89
|
-
render(
|
|
90
|
-
<Card isSelected isSelectableRaised>
|
|
91
|
-
raised selected card
|
|
92
|
-
</Card>
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const card = screen.getByText('raised selected card');
|
|
96
|
-
expect(card).toHaveClass('pf-m-selectable-raised');
|
|
97
|
-
expect(card).toHaveClass('pf-m-selected-raised');
|
|
98
|
-
expect(card).toHaveAttribute('tabindex', '0');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// TODO: Update with issue #9991
|
|
102
|
-
xtest('card with isFlat applied', () => {
|
|
103
|
-
render(<Card isFlat>flat card</Card>);
|
|
104
|
-
expect(screen.getByText('flat card')).toHaveClass('pf-m-flat');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
72
|
test('card with isExpanded applied', () => {
|
|
108
73
|
render(<Card isExpanded>expanded card</Card>);
|
|
109
74
|
expect(screen.getByText('expanded card')).toHaveClass('pf-m-expanded');
|
|
110
75
|
});
|
|
111
76
|
|
|
112
|
-
// TODO: Update with issue #9991
|
|
113
|
-
xtest('card with isRounded applied', () => {
|
|
114
|
-
render(<Card isRounded>rounded card</Card>);
|
|
115
|
-
expect(screen.getByText('rounded card')).toHaveClass('pf-m-rounded');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
77
|
test('card with isLarge applied', () => {
|
|
119
78
|
render(<Card isLarge>large card</Card>);
|
|
120
79
|
expect(screen.getByText('large card')).toHaveClass('pf-m-display-lg');
|
|
@@ -128,87 +87,10 @@ describe('Card', () => {
|
|
|
128
87
|
expect(consoleWarnMock).toHaveBeenCalled();
|
|
129
88
|
});
|
|
130
89
|
|
|
131
|
-
test('card
|
|
132
|
-
render(<Card
|
|
133
|
-
|
|
134
|
-
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
135
|
-
|
|
136
|
-
expect(selectableInput).toBeInTheDocument();
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
test('card does not render the hidden input when hasSelectableInput is not passed', () => {
|
|
140
|
-
render(<Card isSelectable />);
|
|
141
|
-
|
|
142
|
-
const selectableInput = screen.queryByRole('checkbox', { hidden: true });
|
|
143
|
-
|
|
144
|
-
expect(selectableInput).not.toBeInTheDocument();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
test('card warns when hasSelectableInput is passed without selectableInputAriaLabel or a card title', () => {
|
|
148
|
-
const consoleWarnMock = jest.fn();
|
|
149
|
-
global.console = { warn: consoleWarnMock } as any;
|
|
150
|
-
|
|
151
|
-
render(<Card isSelectable hasSelectableInput />);
|
|
152
|
-
|
|
153
|
-
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
154
|
-
|
|
155
|
-
expect(consoleWarnMock).toBeCalled();
|
|
156
|
-
expect(selectableInput).toHaveAccessibleName('');
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test('card applies selectableInputAriaLabel to the hidden input', () => {
|
|
160
|
-
render(<Card isSelectable hasSelectableInput selectableInputAriaLabel="Input label test" />);
|
|
161
|
-
|
|
162
|
-
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
163
|
-
|
|
164
|
-
expect(selectableInput).toHaveAccessibleName('Input label test');
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test('card applies the supplied card title as the aria label of the hidden input', () => {
|
|
168
|
-
// this component is used to mock the CardTitle's title registry behavior to keep this a pure unit test
|
|
169
|
-
const MockCardTitle = ({ children }) => {
|
|
170
|
-
const { registerTitleId } = React.useContext(CardContext);
|
|
171
|
-
const id = 'card-title-id';
|
|
172
|
-
|
|
173
|
-
React.useEffect(() => {
|
|
174
|
-
registerTitleId(id);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
return <div id={id}>{children}</div>;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
render(
|
|
181
|
-
<Card id="card" isSelectable hasSelectableInput>
|
|
182
|
-
<MockCardTitle>Card title from title component</MockCardTitle>
|
|
183
|
-
</Card>
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
187
|
-
|
|
188
|
-
expect(selectableInput).toHaveAccessibleName('Card title from title component');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('card prioritizes selectableInputAriaLabel over card title labelling via card title', () => {
|
|
192
|
-
// this component is used to mock the CardTitle's title registry behavior to keep this a pure unit test
|
|
193
|
-
const MockCardTitle = ({ children }) => {
|
|
194
|
-
const { registerTitleId } = React.useContext(CardContext);
|
|
195
|
-
const id = 'card-title-id';
|
|
196
|
-
|
|
197
|
-
React.useEffect(() => {
|
|
198
|
-
registerTitleId(id);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
return <div id={id}>{children}</div>;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
render(
|
|
205
|
-
<Card id="card" isSelectable hasSelectableInput selectableInputAriaLabel="Input label test">
|
|
206
|
-
<MockCardTitle>Card title from title component</MockCardTitle>
|
|
207
|
-
</Card>
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
const selectableInput = screen.getByRole('checkbox', { hidden: true });
|
|
90
|
+
test('card with variant set to secondary ', () => {
|
|
91
|
+
render(<Card variant="secondary">secondary card</Card>);
|
|
211
92
|
|
|
212
|
-
|
|
93
|
+
const card = screen.getByText('secondary card');
|
|
94
|
+
expect(card).toHaveClass('pf-m-secondary');
|
|
213
95
|
});
|
|
214
96
|
});
|