@patternfly/react-core 6.0.0-alpha.30 → 6.0.0-alpha.31
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/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/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/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/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.30","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.30","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.30","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.31",
|
|
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": "9a345255141c46054b410c0b06a4ef2bb6e55e91"
|
|
77
77
|
}
|
|
@@ -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
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
import { CardTitle } from '../CardTitle';
|
|
4
|
-
import { CardContext } from '../Card';
|
|
5
4
|
|
|
6
5
|
describe('CardTitle', () => {
|
|
7
6
|
test('renders with PatternFly Core styles', () => {
|
|
@@ -20,16 +19,4 @@ describe('CardTitle', () => {
|
|
|
20
19
|
render(<CardTitle data-testid={testId} />);
|
|
21
20
|
expect(screen.getByTestId(testId)).toBeInTheDocument();
|
|
22
21
|
});
|
|
23
|
-
|
|
24
|
-
test('calls the registerTitleId function provided by the CardContext with the generated title id', () => {
|
|
25
|
-
const mockRegisterTitleId = jest.fn();
|
|
26
|
-
|
|
27
|
-
render(
|
|
28
|
-
<CardContext.Provider value={{ cardId: 'card', registerTitleId: mockRegisterTitleId }}>
|
|
29
|
-
<CardTitle>text</CardTitle>
|
|
30
|
-
</CardContext.Provider>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
expect(mockRegisterTitleId).toHaveBeenCalledWith('card-title');
|
|
34
|
-
});
|
|
35
22
|
});
|
|
@@ -16,8 +16,8 @@ propComponents:
|
|
|
16
16
|
ouia: true
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
import pfLogo from '../../assets/
|
|
20
|
-
import pfLogoSmall from '../../assets/
|
|
19
|
+
import pfLogo from '../../assets/PF-HorizontalLogo-Color.svg';
|
|
20
|
+
import pfLogoSmall from '../../assets/PF-IconLogo.svg';
|
|
21
21
|
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
22
22
|
|
|
23
23
|
## Examples
|
|
@@ -30,6 +30,14 @@ Basic cards typically have a `<CardTitle>`, `<CardBody>` and `<CardFooter>`. You
|
|
|
30
30
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
### Secondary cards
|
|
34
|
+
|
|
35
|
+
You can apply secondary background color styling to a card by setting the `variant` property to `secondary`.
|
|
36
|
+
|
|
37
|
+
```ts file='./CardSecondary.tsx'
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
|
|
33
41
|
### Modifiers
|
|
34
42
|
|
|
35
43
|
You can further modify the styling of the card's content by using the properties outlined below. In this example, you can enable each modifier by selecting its respective checkbox.
|
|
@@ -43,8 +51,6 @@ Most modifiers can be used in combination with each other, except for `isCompact
|
|
|
43
51
|
| Modifier | Description |
|
|
44
52
|
| ------------ | ------------------------------------------------------------------------------------ |
|
|
45
53
|
| isCompact | Modifies the card to include compact styling. Should not be used with isLarge. |
|
|
46
|
-
| isFlat | Modifies the card to include flat styling. |
|
|
47
|
-
| isRounded | Modifies the card to include rounded border styling. |
|
|
48
54
|
| isLarge | Modifies the card to be large. Should not be used with isCompact. |
|
|
49
55
|
| isFullHeight | Modifies the card so that it fills the total available height of its container. |
|
|
50
56
|
| isPlain | Modifies the card to include plain styling, which removes the border and background. |
|
|
@@ -145,36 +151,6 @@ When passing interactive content to a clickable and selectable card that is disa
|
|
|
145
151
|
|
|
146
152
|
```
|
|
147
153
|
|
|
148
|
-
### Selectable cards (deprecated)
|
|
149
|
-
|
|
150
|
-
The following example shows a deprecated implementation of selectable cards. This example uses the `isSelectable` property instead of `isSelectableRaised`, which is the current recommendation for implementation. `isSelectable` applies selectable styling, but does not apply raised styling on hover and selection as `isSelectableRaised` does.
|
|
151
|
-
|
|
152
|
-
A `tabIndex={0}` is also manually passed to allow the card to be focused and clicked via keyboard.
|
|
153
|
-
|
|
154
|
-
```ts file='./CardDeprecatedSelectable.tsx' isDeprecated
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Selectable card accessibility features (deprecated)
|
|
159
|
-
|
|
160
|
-
Note: the following example uses deprecated properties. We recommend using the new `selectableActions` property for the `CardHeader` instead.
|
|
161
|
-
|
|
162
|
-
The following cards demonstrate how the `hasSelectableInput` and `onSelectableInputChange` properties improve accessibility for selectable cards.
|
|
163
|
-
|
|
164
|
-
The first card sets `hasSelectableInput` to true, which renders a checkbox input that is only visible to, and navigable by, screen readers. This input communicates to assistive technology users that a card is selectable, and if so, also communicates the current selection state.
|
|
165
|
-
|
|
166
|
-
By default, this input will have an aria-label that corresponds to the `<CardTitle>`. If this isn't defined, then you must pass a custom aria-label using the `selectableInputAriaLabel` property.
|
|
167
|
-
|
|
168
|
-
The first card passes an onChange callback to `onSelectableInputChange` to enable the selection/deselection of the associated card via checkbox input.
|
|
169
|
-
|
|
170
|
-
The second card does not set `hasSelectableInput` to true, so neither the input nor the selection state is communicated to users of assistive technologies.
|
|
171
|
-
|
|
172
|
-
We recommend navigating this example using a screen reader to best understand both cards.
|
|
173
|
-
|
|
174
|
-
```ts file='./CardDeprecatedSelectableA11yHighlight.tsx' isDeprecated
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
|
|
178
154
|
### Expandable cards
|
|
179
155
|
|
|
180
156
|
A card can be made expandable using the `isExpanded` property. In the collapsed state, only the card header is shown, and the user can click the caret to view the rest of the card content.
|
|
@@ -192,3 +168,10 @@ An image can be placed in the card header to show users an icon beside the expan
|
|
|
192
168
|
```ts file='./CardExpandableWithIcon.tsx'
|
|
193
169
|
|
|
194
170
|
```
|
|
171
|
+
|
|
172
|
+
### Card with dividers
|
|
173
|
+
Dividers can be placed between sections of the card.
|
|
174
|
+
|
|
175
|
+
```ts file='./CardWithDividers.tsx'
|
|
176
|
+
|
|
177
|
+
```
|
|
@@ -1,54 +1,72 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Card, CardHeader, CardTitle, CardBody } from '@patternfly/react-core';
|
|
2
|
+
import { Card, CardHeader, CardTitle, CardBody, Checkbox, Gallery } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
4
|
export const CardClickable: React.FunctionComponent = () => {
|
|
5
|
+
const [isSecondary, setIsSecondary] = React.useState<boolean>(false);
|
|
6
|
+
|
|
5
7
|
const id1 = 'clickable-card-input-1';
|
|
6
8
|
const id2 = 'clickable-card-input-2';
|
|
7
9
|
const id3 = 'clickable-card-input-3';
|
|
8
10
|
|
|
11
|
+
const toggleVariant = (checked: boolean) => {
|
|
12
|
+
setIsSecondary(checked);
|
|
13
|
+
};
|
|
14
|
+
|
|
9
15
|
return (
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
>
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
16
|
+
<>
|
|
17
|
+
<Checkbox
|
|
18
|
+
label="secondary styling"
|
|
19
|
+
isChecked={isSecondary}
|
|
20
|
+
onChange={(_event, checked) => toggleVariant(checked)}
|
|
21
|
+
aria-label="add secondary styling"
|
|
22
|
+
id="toggle-variant-clickable"
|
|
23
|
+
name="toggle-variant"
|
|
24
|
+
/>
|
|
25
|
+
<div style={{ marginTop: '15px' }}>
|
|
26
|
+
<Gallery hasGutter>
|
|
27
|
+
<Card id="clickable-card-example-1" isClickable variant={isSecondary ? 'secondary' : 'default'}>
|
|
28
|
+
<CardHeader
|
|
29
|
+
selectableActions={{
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
onClickAction: () => console.log(`${id1} clicked`),
|
|
32
|
+
selectableActionId: id1,
|
|
33
|
+
selectableActionAriaLabelledby: 'clickable-card-example-1',
|
|
34
|
+
name: 'clickable-card-example'
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<CardTitle>First card</CardTitle>
|
|
38
|
+
</CardHeader>
|
|
39
|
+
<CardBody>This card performs an action on click.</CardBody>
|
|
40
|
+
</Card>
|
|
41
|
+
<Card id="clickable-card-example-2" isClickable variant={isSecondary ? 'secondary' : 'default'}>
|
|
42
|
+
<CardHeader
|
|
43
|
+
selectableActions={{
|
|
44
|
+
to: '#',
|
|
45
|
+
selectableActionId: id2,
|
|
46
|
+
selectableActionAriaLabelledby: 'clickable-card-example-2',
|
|
47
|
+
name: 'clickable-card-example'
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<CardTitle>Second card</CardTitle>
|
|
51
|
+
</CardHeader>
|
|
52
|
+
<CardBody>This card can navigate to a link on click.</CardBody>
|
|
53
|
+
</Card>
|
|
54
|
+
<Card id="clickable-card-example-3" isClickable isDisabled variant={isSecondary ? 'secondary' : 'default'}>
|
|
55
|
+
<CardHeader
|
|
56
|
+
selectableActions={{
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
58
|
+
onClickAction: () => console.log(`${id3} clicked`),
|
|
59
|
+
selectableActionId: id3,
|
|
60
|
+
selectableActionAriaLabelledby: 'clickable-card-example-3',
|
|
61
|
+
name: 'clickable-card-example'
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<CardTitle>Third card</CardTitle>
|
|
65
|
+
</CardHeader>
|
|
66
|
+
<CardBody>This card is clickable but disabled.</CardBody>
|
|
67
|
+
</Card>
|
|
68
|
+
</Gallery>
|
|
69
|
+
</div>
|
|
70
|
+
</>
|
|
53
71
|
);
|
|
54
72
|
};
|