@patternfly/react-core 4.178.0 → 4.179.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.178.0",
3
+ "version": "4.179.0",
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",
@@ -34,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.29.0",
38
- "@patternfly/react-styles": "^4.28.0",
39
- "@patternfly/react-tokens": "^4.30.0",
37
+ "@patternfly/react-icons": "^4.30.0",
38
+ "@patternfly/react-styles": "^4.29.0",
39
+ "@patternfly/react-tokens": "^4.31.0",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },
63
- "gitHead": "a9bc2138a7f93fccc6f97864af5b8a642c75ba8a"
63
+ "gitHead": "d40749c27a4a05e65a465179ee15ecd10df78e38"
64
64
  }
@@ -12,20 +12,18 @@ export interface CardProps extends React.HTMLProps<HTMLElement>, OUIAProps {
12
12
  className?: string;
13
13
  /** Sets the base component to render. defaults to article */
14
14
  component?: keyof JSX.IntrinsicElements;
15
- /** Modifies the card to include hover styles on :hover */
15
+ /** @deprecated to make a card hoverable, use isSelectable or isSelectableRaised. */
16
16
  isHoverable?: boolean;
17
- /** @beta Modifies the card to include hoverable-raised styles on :hover, this styling is included by default with isSelectableRaised */
18
- isHoverableRaised?: boolean;
19
17
  /** Modifies the card to include compact styling. Should not be used with isLarge. */
20
18
  isCompact?: boolean;
21
19
  /** Modifies the card to include selectable styling */
22
20
  isSelectable?: boolean;
21
+ /** @beta Specifies the card is selectable, and applies the new raised styling on hover and select */
22
+ isSelectableRaised?: boolean;
23
23
  /** Modifies the card to include selected styling */
24
24
  isSelected?: boolean;
25
- /** @beta Modifies the card to include selectable-raised styling and hoverable-raised styling */
26
- isSelectableRaised?: boolean;
27
- /** @beta Modifies the card to include selected-raised styling */
28
- isSelectedRaised?: boolean;
25
+ /** @beta Modifies a raised selectable card to have disabled styling */
26
+ isDisabledRaised?: boolean;
29
27
  /** Modifies the card to include flat styling */
30
28
  isFlat?: boolean;
31
29
  /** Modifies the card to include rounded styling */
@@ -56,12 +54,11 @@ export const Card: React.FunctionComponent<CardProps> = ({
56
54
  className = '',
57
55
  component = 'article',
58
56
  isHoverable = false,
59
- isHoverableRaised = false,
60
57
  isCompact = false,
61
58
  isSelectable = false,
62
- isSelected = false,
63
59
  isSelectableRaised = false,
64
- isSelectedRaised = false,
60
+ isSelected = false,
61
+ isDisabledRaised = false,
65
62
  isFlat = false,
66
63
  isExpanded = false,
67
64
  isRounded = false,
@@ -79,6 +76,20 @@ export const Card: React.FunctionComponent<CardProps> = ({
79
76
  console.warn('Card: Cannot use isCompact with isLarge. Defaulting to isCompact');
80
77
  isLarge = false;
81
78
  }
79
+
80
+ const getSelectableModifiers = () => {
81
+ if (isDisabledRaised) {
82
+ return css(styles.modifiers.nonSelectableRaised);
83
+ }
84
+ if (isSelectableRaised) {
85
+ return css(styles.modifiers.selectableRaised, isSelected && styles.modifiers.selectedRaised);
86
+ }
87
+ if (isSelectable || isHoverable) {
88
+ return css(styles.modifiers.selectable, isSelected && styles.modifiers.selected);
89
+ }
90
+ return '';
91
+ };
92
+
82
93
  return (
83
94
  <CardContext.Provider
84
95
  value={{
@@ -90,22 +101,17 @@ export const Card: React.FunctionComponent<CardProps> = ({
90
101
  id={id}
91
102
  className={css(
92
103
  styles.card,
93
- isHoverable && styles.modifiers.hoverable,
94
- isHoverableRaised && styles.modifiers.hoverableRaised,
95
104
  isCompact && styles.modifiers.compact,
96
- isSelectable && !isSelectableRaised && styles.modifiers.selectable,
97
- isSelected && !isSelectedRaised && isSelectable && styles.modifiers.selected,
98
- isSelectableRaised && styles.modifiers.selectableRaised,
99
- isSelectedRaised && isSelectableRaised && styles.modifiers.selectedRaised,
100
105
  isExpanded && styles.modifiers.expanded,
101
106
  isFlat && styles.modifiers.flat,
102
107
  isRounded && styles.modifiers.rounded,
103
108
  isLarge && styles.modifiers.displayLg,
104
109
  isFullHeight && styles.modifiers.fullHeight,
105
110
  isPlain && styles.modifiers.plain,
111
+ getSelectableModifiers(),
106
112
  className
107
113
  )}
108
- tabIndex={isSelectableRaised || isSelectable ? '0' : undefined}
114
+ tabIndex={isSelectable || isSelectableRaised ? '0' : undefined}
109
115
  {...props}
110
116
  {...ouiaProps}
111
117
  >
@@ -35,11 +35,6 @@ test('card with isHoverable applied ', () => {
35
35
  expect(view).toMatchSnapshot();
36
36
  });
37
37
 
38
- test('card with isHoverableRaised applied ', () => {
39
- const view = shallow(<Card isHoverableRaised />).dive();
40
- expect(view).toMatchSnapshot();
41
- });
42
-
43
38
  test('card with isCompact applied ', () => {
44
39
  const view = shallow(<Card isCompact />).dive();
45
40
  expect(view).toMatchSnapshot();
@@ -64,25 +59,24 @@ test('card with only isSelected applied - not change', () => {
64
59
  expect(view.prop('tabIndex')).toBe(undefined);
65
60
  });
66
61
 
67
- test('card with isSelectableRaised applied ', () => {
62
+ test('card with isDisabledRaised applied', () => {
63
+ const view = shallow(<Card isDisabledRaised />).dive();
64
+ expect(view.prop('className')).toMatch(/non-selectable-raised/);
65
+ });
66
+
67
+ test('card with isSelectableRaised applied - not change', () => {
68
68
  const view = shallow(<Card isSelectableRaised />).dive();
69
69
  expect(view.prop('className')).toMatch(/selectable-raised/);
70
70
  expect(view.prop('tabIndex')).toBe('0');
71
71
  });
72
72
 
73
- test('card with isSelectableRaised and isSelectedRaised applied ', () => {
74
- const view = shallow(<Card isSelectableRaised isSelectedRaised />).dive();
73
+ test('card with isSelectableRaised and isSelected applied ', () => {
74
+ const view = shallow(<Card isSelected isSelectableRaised />).dive();
75
75
  expect(view.prop('className')).toMatch(/selectable-raised/);
76
76
  expect(view.prop('className')).toMatch(/selected-raised/);
77
77
  expect(view.prop('tabIndex')).toBe('0');
78
78
  });
79
79
 
80
- test('card with only isSelectedRaised applied - not change', () => {
81
- const view = shallow(<Card isSelectedRaised />).dive();
82
- expect(view.prop('className')).not.toMatch(/selected-raised/);
83
- expect(view.prop('tabIndex')).toBe(undefined);
84
- });
85
-
86
80
  test('card with isFlat applied', () => {
87
81
  const view = shallow(<Card isFlat />).dive();
88
82
  expect(view.prop('className')).toMatch(/m-flat/);
@@ -3,7 +3,7 @@
3
3
  exports[`card with isCompact applied 1`] = `
4
4
  <article
5
5
  className="pf-c-card pf-m-compact"
6
- data-ouia-component-id="OUIA-Generated-Card-8"
6
+ data-ouia-component-id="OUIA-Generated-Card-7"
7
7
  data-ouia-component-type="PF4/Card"
8
8
  data-ouia-safe={true}
9
9
  id=""
@@ -12,7 +12,7 @@ exports[`card with isCompact applied 1`] = `
12
12
 
13
13
  exports[`card with isHoverable applied 1`] = `
14
14
  <article
15
- className="pf-c-card pf-m-hoverable"
15
+ className="pf-c-card pf-m-selectable"
16
16
  data-ouia-component-id="OUIA-Generated-Card-6"
17
17
  data-ouia-component-type="PF4/Card"
18
18
  data-ouia-safe={true}
@@ -20,16 +20,6 @@ exports[`card with isHoverable applied 1`] = `
20
20
  />
21
21
  `;
22
22
 
23
- exports[`card with isHoverableRaised applied 1`] = `
24
- <article
25
- className="pf-c-card pf-m-hoverable-raised"
26
- data-ouia-component-id="OUIA-Generated-Card-7"
27
- data-ouia-component-type="PF4/Card"
28
- data-ouia-safe={true}
29
- id=""
30
- />
31
- `;
32
-
33
23
  exports[`className is added to the root element 1`] = `"pf-c-card extra-class"`;
34
24
 
35
25
  exports[`renders with PatternFly Core styles 1`] = `