@patternfly/react-core 4.157.6 → 4.158.1

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.
Files changed (26) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/esm/components/JumpLinks/JumpLinks.d.ts.map +1 -1
  3. package/dist/esm/components/JumpLinks/JumpLinks.js +7 -3
  4. package/dist/esm/components/JumpLinks/JumpLinks.js.map +1 -1
  5. package/dist/esm/components/TreeView/TreeViewListItem.d.ts +1 -1
  6. package/dist/esm/components/TreeView/TreeViewListItem.d.ts.map +1 -1
  7. package/dist/esm/components/TreeView/TreeViewListItem.js +4 -6
  8. package/dist/esm/components/TreeView/TreeViewListItem.js.map +1 -1
  9. package/dist/js/components/JumpLinks/JumpLinks.d.ts.map +1 -1
  10. package/dist/js/components/JumpLinks/JumpLinks.js +7 -3
  11. package/dist/js/components/JumpLinks/JumpLinks.js.map +1 -1
  12. package/dist/js/components/TreeView/TreeViewListItem.d.ts +1 -1
  13. package/dist/js/components/TreeView/TreeViewListItem.d.ts.map +1 -1
  14. package/dist/js/components/TreeView/TreeViewListItem.js +4 -6
  15. package/dist/js/components/TreeView/TreeViewListItem.js.map +1 -1
  16. package/dist/umd/react-core.css +10687 -10698
  17. package/dist/umd/react-core.js +14 -12
  18. package/dist/umd/react-core.min.css +12871 -12882
  19. package/dist/umd/react-core.min.js +1 -1
  20. package/package.json +6 -6
  21. package/src/components/JumpLinks/JumpLinks.tsx +3 -6
  22. package/src/components/JumpLinks/__tests__/JumpLinks.test.tsx +68 -0
  23. package/src/components/JumpLinks/__tests__/__snapshots__/JumpLinks.test.tsx.snap +210 -0
  24. package/src/components/TreeView/TreeViewListItem.tsx +5 -9
  25. package/src/layouts/Grid/__tests__/GridItem.test.tsx +1 -1
  26. package/src/layouts/Grid/__tests__/__snapshots__/GridItem.test.tsx.snap +18 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.157.6",
3
+ "version": "4.158.1",
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,16 +34,16 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.11.17",
38
- "@patternfly/react-styles": "^4.11.16",
39
- "@patternfly/react-tokens": "^4.12.18",
37
+ "@patternfly/react-icons": "^4.12.0",
38
+ "@patternfly/react-styles": "^4.12.0",
39
+ "@patternfly/react-tokens": "^4.13.0",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
43
43
  "tslib": "^2.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@patternfly/patternfly": "4.135.2",
46
+ "@patternfly/patternfly": "4.135.4",
47
47
  "@rollup/plugin-commonjs": "^11.0.2",
48
48
  "@rollup/plugin-node-resolve": "^7.1.1",
49
49
  "@rollup/plugin-replace": "^2.3.1",
@@ -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": "d013adc9687d5873a6733b63ff6bc2d93a2b5915"
63
+ "gitHead": "0345fe8126e2e5ff7746377fd6ba344d93ec24a3"
64
64
  }
@@ -219,7 +219,7 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
219
219
  {...props}
220
220
  >
221
221
  <div className={styles.jumpLinksMain}>
222
- <div className={styles.jumpLinksHeader}>
222
+ <div className={css('pf-c-jump-links__header')}>
223
223
  {expandable && (
224
224
  <div className={styles.jumpLinksToggle}>
225
225
  <Button
@@ -231,14 +231,11 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
231
231
  <span className={styles.jumpLinksToggleIcon}>
232
232
  <AngleRightIcon />
233
233
  </span>
234
+ {label && <span className={css(styles.jumpLinksToggleText)}> {label} </span>}
234
235
  </Button>
235
236
  </div>
236
237
  )}
237
- {label && (
238
- <div className={css(styles.jumpLinksLabel, expandable && !alwaysShowLabel && styles.modifiers.toggle)}>
239
- {label}
240
- </div>
241
- )}
238
+ {label && alwaysShowLabel && <div className={css(styles.jumpLinksLabel)}>{label}</div>}
242
239
  </div>
243
240
  <ul className={styles.jumpLinksList}>{cloneChildren(children)}</ul>
244
241
  </div>
@@ -0,0 +1,68 @@
1
+ import * as React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import { JumpLinks } from '../JumpLinks';
4
+ import { JumpLinksItem } from '../JumpLinksItem';
5
+ import { JumpLinksList } from '../JumpLinksList';
6
+
7
+ test('simple jumplinks', () => {
8
+ const view = shallow(
9
+ <JumpLinks>
10
+ <JumpLinksItem>Inactive section</JumpLinksItem>
11
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
12
+ <JumpLinksItem>Inactive section</JumpLinksItem>
13
+ </JumpLinks>
14
+ );
15
+ expect(view).toMatchSnapshot();
16
+ });
17
+
18
+ test('jumplinks centered', () => {
19
+ const view = shallow(
20
+ <JumpLinks isCentered>
21
+ <JumpLinksItem>Inactive section</JumpLinksItem>
22
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
23
+ <JumpLinksItem>Inactive section</JumpLinksItem>
24
+ </JumpLinks>
25
+ );
26
+ expect(view).toMatchSnapshot();
27
+ });
28
+
29
+ test('jumplinks with label', () => {
30
+ const view = shallow(
31
+ <JumpLinks isCentered label="Jump to section">
32
+ <JumpLinksItem>Inactive section</JumpLinksItem>
33
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
34
+ <JumpLinksItem>Inactive section</JumpLinksItem>
35
+ </JumpLinks>
36
+ );
37
+ expect(view).toMatchSnapshot();
38
+ });
39
+
40
+ test('vertical with label', () => {
41
+ const view = shallow(
42
+ <JumpLinks isVertical alwaysShowLabel label="Jump to section">
43
+ <JumpLinksItem>Inactive section</JumpLinksItem>
44
+ <JumpLinksItem isActive>Active section</JumpLinksItem>
45
+ <JumpLinksItem>Inactive section</JumpLinksItem>
46
+ </JumpLinks>
47
+ );
48
+ expect(view).toMatchSnapshot();
49
+ });
50
+
51
+ test('expandable vertical with subsection', () => {
52
+ const view = shallow(
53
+ <JumpLinks isVertical label="Jump to section" expandable={{ default: 'expandable' }}>
54
+ <JumpLinksItem>Inactive section</JumpLinksItem>
55
+ <JumpLinksItem>
56
+ Section with active subsection
57
+ <JumpLinksList>
58
+ <JumpLinksItem isActive>Active subsection</JumpLinksItem>
59
+ <JumpLinksItem>Inactive subsection</JumpLinksItem>
60
+ <JumpLinksItem>Inactive subsection</JumpLinksItem>
61
+ </JumpLinksList>
62
+ </JumpLinksItem>
63
+ <JumpLinksItem>Inactive section</JumpLinksItem>
64
+ <JumpLinksItem>Inactive section</JumpLinksItem>
65
+ </JumpLinks>
66
+ );
67
+ expect(view).toMatchSnapshot();
68
+ });
@@ -0,0 +1,210 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`expandable vertical with subsection 1`] = `
4
+ <nav
5
+ aria-label="Jump to section"
6
+ className="pf-c-jump-links pf-m-vertical pf-m-expandable"
7
+ >
8
+ <div
9
+ className="pf-c-jump-links__main"
10
+ >
11
+ <div
12
+ className="pf-c-jump-links__header"
13
+ >
14
+ <div
15
+ className="pf-c-jump-links__toggle"
16
+ >
17
+ <Button
18
+ aria-expanded={false}
19
+ aria-label="Toggle jump links"
20
+ onClick={[Function]}
21
+ variant="plain"
22
+ >
23
+ <span
24
+ className="pf-c-jump-links__toggle-icon"
25
+ >
26
+ <AngleRightIcon
27
+ color="currentColor"
28
+ noVerticalAlign={false}
29
+ size="sm"
30
+ />
31
+ </span>
32
+ <span
33
+ className="pf-c-jump-links__toggle-text"
34
+ >
35
+
36
+ Jump to section
37
+
38
+ </span>
39
+ </Button>
40
+ </div>
41
+ <div
42
+ className="pf-c-jump-links__label"
43
+ >
44
+ Jump to section
45
+ </div>
46
+ </div>
47
+ <ul
48
+ className="pf-c-jump-links__list"
49
+ >
50
+ <JumpLinksItem>
51
+ Inactive section
52
+ </JumpLinksItem>
53
+ <JumpLinksItem>
54
+ Section with active subsection
55
+ <JumpLinksList>
56
+ <JumpLinksItem
57
+ isActive={true}
58
+ >
59
+ Active subsection
60
+ </JumpLinksItem>
61
+ <JumpLinksItem>
62
+ Inactive subsection
63
+ </JumpLinksItem>
64
+ <JumpLinksItem>
65
+ Inactive subsection
66
+ </JumpLinksItem>
67
+ </JumpLinksList>
68
+ </JumpLinksItem>
69
+ <JumpLinksItem>
70
+ Inactive section
71
+ </JumpLinksItem>
72
+ <JumpLinksItem>
73
+ Inactive section
74
+ </JumpLinksItem>
75
+ </ul>
76
+ </div>
77
+ </nav>
78
+ `;
79
+
80
+ exports[`jumplinks centered 1`] = `
81
+ <nav
82
+ aria-label={null}
83
+ className="pf-c-jump-links pf-m-center"
84
+ >
85
+ <div
86
+ className="pf-c-jump-links__main"
87
+ >
88
+ <div
89
+ className="pf-c-jump-links__header"
90
+ />
91
+ <ul
92
+ className="pf-c-jump-links__list"
93
+ >
94
+ <JumpLinksItem>
95
+ Inactive section
96
+ </JumpLinksItem>
97
+ <JumpLinksItem
98
+ isActive={true}
99
+ >
100
+ Active section
101
+ </JumpLinksItem>
102
+ <JumpLinksItem>
103
+ Inactive section
104
+ </JumpLinksItem>
105
+ </ul>
106
+ </div>
107
+ </nav>
108
+ `;
109
+
110
+ exports[`jumplinks with label 1`] = `
111
+ <nav
112
+ aria-label="Jump to section"
113
+ className="pf-c-jump-links pf-m-center"
114
+ >
115
+ <div
116
+ className="pf-c-jump-links__main"
117
+ >
118
+ <div
119
+ className="pf-c-jump-links__header"
120
+ >
121
+ <div
122
+ className="pf-c-jump-links__label"
123
+ >
124
+ Jump to section
125
+ </div>
126
+ </div>
127
+ <ul
128
+ className="pf-c-jump-links__list"
129
+ >
130
+ <JumpLinksItem>
131
+ Inactive section
132
+ </JumpLinksItem>
133
+ <JumpLinksItem
134
+ isActive={true}
135
+ >
136
+ Active section
137
+ </JumpLinksItem>
138
+ <JumpLinksItem>
139
+ Inactive section
140
+ </JumpLinksItem>
141
+ </ul>
142
+ </div>
143
+ </nav>
144
+ `;
145
+
146
+ exports[`simple jumplinks 1`] = `
147
+ <nav
148
+ aria-label={null}
149
+ className="pf-c-jump-links"
150
+ >
151
+ <div
152
+ className="pf-c-jump-links__main"
153
+ >
154
+ <div
155
+ className="pf-c-jump-links__header"
156
+ />
157
+ <ul
158
+ className="pf-c-jump-links__list"
159
+ >
160
+ <JumpLinksItem>
161
+ Inactive section
162
+ </JumpLinksItem>
163
+ <JumpLinksItem
164
+ isActive={true}
165
+ >
166
+ Active section
167
+ </JumpLinksItem>
168
+ <JumpLinksItem>
169
+ Inactive section
170
+ </JumpLinksItem>
171
+ </ul>
172
+ </div>
173
+ </nav>
174
+ `;
175
+
176
+ exports[`vertical with label 1`] = `
177
+ <nav
178
+ aria-label="Jump to section"
179
+ className="pf-c-jump-links pf-m-vertical"
180
+ >
181
+ <div
182
+ className="pf-c-jump-links__main"
183
+ >
184
+ <div
185
+ className="pf-c-jump-links__header"
186
+ >
187
+ <div
188
+ className="pf-c-jump-links__label"
189
+ >
190
+ Jump to section
191
+ </div>
192
+ </div>
193
+ <ul
194
+ className="pf-c-jump-links__list"
195
+ >
196
+ <JumpLinksItem>
197
+ Inactive section
198
+ </JumpLinksItem>
199
+ <JumpLinksItem
200
+ isActive={true}
201
+ >
202
+ Active section
203
+ </JumpLinksItem>
204
+ <JumpLinksItem>
205
+ Inactive section
206
+ </JumpLinksItem>
207
+ </ul>
208
+ </div>
209
+ </nav>
210
+ `;
@@ -23,7 +23,7 @@ export interface TreeViewListItemProps {
23
23
  defaultExpanded?: boolean;
24
24
  /** Child nodes of a tree view item */
25
25
  children?: React.ReactNode;
26
- /** Callback for item selection */
26
+ /** Callback for item selection. Note: calling event.preventDefault() will prevent the node from toggling. */
27
27
  onSelect?: (event: React.MouseEvent, item: TreeViewDataItem, parent: TreeViewDataItem) => void;
28
28
  /** Callback for item checkbox selection */
29
29
  onCheck?: (event: React.ChangeEvent, item: TreeViewDataItem, parent: TreeViewDataItem) => void;
@@ -85,14 +85,10 @@ export const TreeViewListItem: React.FunctionComponent<TreeViewListItemProps> =
85
85
  useEffect(() => {
86
86
  if (isExpanded !== undefined && isExpanded !== null) {
87
87
  setIsExpanded(isExpanded);
88
- }
89
- }, [isExpanded]);
90
-
91
- useEffect(() => {
92
- if (defaultExpanded !== undefined && defaultExpanded !== null) {
88
+ } else if (defaultExpanded !== undefined && defaultExpanded !== null) {
93
89
  setIsExpanded(internalIsExpanded || defaultExpanded);
94
90
  }
95
- }, [defaultExpanded]);
91
+ }, [isExpanded, defaultExpanded]);
96
92
 
97
93
  const Component = hasCheck ? 'div' : 'button';
98
94
  const ToggleComponent = hasCheck ? 'button' : 'div';
@@ -186,10 +182,10 @@ export const TreeViewListItem: React.FunctionComponent<TreeViewListItemProps> =
186
182
  )}
187
183
  onClick={(evt: React.MouseEvent) => {
188
184
  if (!hasCheck) {
189
- if (children) {
185
+ onSelect && onSelect(evt, itemData, parentItem);
186
+ if (children && evt.isDefaultPrevented() !== true) {
190
187
  setIsExpanded(!internalIsExpanded);
191
188
  }
192
- onSelect && onSelect(evt, itemData, parentItem);
193
189
  }
194
190
  }}
195
191
  {...(!children && { role: 'treeitem' })}
@@ -18,7 +18,7 @@ test('adds row class', () => {
18
18
  expect(view.props().className).toMatchSnapshot();
19
19
  });
20
20
 
21
- Object.values(DeviceSizes).forEach(size => {
21
+ Object.keys(DeviceSizes).forEach(size => {
22
22
  test(`adds ${size} span class`, () => {
23
23
  const props = { [size]: 4 };
24
24
  const view = shallow(<GridItem {...props} />);
@@ -1,37 +1,37 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`adds _2xl offset classes 1`] = `"pf-l-grid__item"`;
3
+ exports[`adds lg offset classes 1`] = `"pf-l-grid__item pf-m-offset-1-col-on-lg"`;
4
4
 
5
- exports[`adds _2xl row classes 1`] = `"pf-l-grid__item"`;
5
+ exports[`adds lg row classes 1`] = `"pf-l-grid__item pf-m-1-row-on-lg"`;
6
6
 
7
- exports[`adds _2xl span class 1`] = `"pf-l-grid__item"`;
7
+ exports[`adds lg span class 1`] = `"pf-l-grid__item pf-m-4-col-on-lg"`;
8
8
 
9
- exports[`adds Lg offset classes 1`] = `"pf-l-grid__item"`;
9
+ exports[`adds md offset classes 1`] = `"pf-l-grid__item pf-m-offset-1-col-on-md"`;
10
10
 
11
- exports[`adds Lg row classes 1`] = `"pf-l-grid__item"`;
11
+ exports[`adds md row classes 1`] = `"pf-l-grid__item pf-m-1-row-on-md"`;
12
12
 
13
- exports[`adds Lg span class 1`] = `"pf-l-grid__item"`;
13
+ exports[`adds md span class 1`] = `"pf-l-grid__item pf-m-4-col-on-md"`;
14
14
 
15
- exports[`adds Md offset classes 1`] = `"pf-l-grid__item"`;
15
+ exports[`adds offset class 1`] = `"pf-l-grid__item pf-m-offset-4-col"`;
16
16
 
17
- exports[`adds Md row classes 1`] = `"pf-l-grid__item"`;
17
+ exports[`adds row class 1`] = `"pf-l-grid__item pf-m-4-row"`;
18
18
 
19
- exports[`adds Md span class 1`] = `"pf-l-grid__item"`;
19
+ exports[`adds sm offset classes 1`] = `"pf-l-grid__item pf-m-offset-1-col-on-sm"`;
20
20
 
21
- exports[`adds Sm offset classes 1`] = `"pf-l-grid__item"`;
21
+ exports[`adds sm row classes 1`] = `"pf-l-grid__item pf-m-1-row-on-sm"`;
22
22
 
23
- exports[`adds Sm row classes 1`] = `"pf-l-grid__item"`;
23
+ exports[`adds sm span class 1`] = `"pf-l-grid__item pf-m-4-col-on-sm"`;
24
24
 
25
- exports[`adds Sm span class 1`] = `"pf-l-grid__item"`;
25
+ exports[`adds span class 1`] = `"pf-l-grid__item pf-m-4-col"`;
26
26
 
27
- exports[`adds Xl offset classes 1`] = `"pf-l-grid__item"`;
27
+ exports[`adds xl offset classes 1`] = `"pf-l-grid__item pf-m-offset-1-col-on-xl"`;
28
28
 
29
- exports[`adds Xl row classes 1`] = `"pf-l-grid__item"`;
29
+ exports[`adds xl row classes 1`] = `"pf-l-grid__item pf-m-1-row-on-xl"`;
30
30
 
31
- exports[`adds Xl span class 1`] = `"pf-l-grid__item"`;
31
+ exports[`adds xl span class 1`] = `"pf-l-grid__item pf-m-4-col-on-xl"`;
32
32
 
33
- exports[`adds offset class 1`] = `"pf-l-grid__item pf-m-offset-4-col"`;
33
+ exports[`adds xl2 offset classes 1`] = `"pf-l-grid__item pf-m-offset-1-col-on-2xl"`;
34
34
 
35
- exports[`adds row class 1`] = `"pf-l-grid__item pf-m-4-row"`;
35
+ exports[`adds xl2 row classes 1`] = `"pf-l-grid__item pf-m-1-row-on-2xl"`;
36
36
 
37
- exports[`adds span class 1`] = `"pf-l-grid__item pf-m-4-col"`;
37
+ exports[`adds xl2 span class 1`] = `"pf-l-grid__item pf-m-4-col-on-2xl"`;