@patternfly/react-core 4.188.1 → 4.189.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.188.1",
3
+ "version": "4.189.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.39.1",
38
- "@patternfly/react-styles": "^4.38.1",
39
- "@patternfly/react-tokens": "^4.40.1",
37
+ "@patternfly/react-icons": "^4.40.0",
38
+ "@patternfly/react-styles": "^4.39.0",
39
+ "@patternfly/react-tokens": "^4.41.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": "21fd06d0acb87d7b579f9710845bf8489d53e800"
63
+ "gitHead": "232be76ce3bb9ee8af7b86f3b0ae3629eb65a761"
64
64
  }
@@ -18,9 +18,12 @@ export enum TabsComponent {
18
18
  nav = 'nav'
19
19
  }
20
20
 
21
+ type TabElement = React.ReactElement<TabProps, React.JSXElementConstructor<TabProps>>;
22
+ type TabsChild = TabElement | boolean | null | undefined;
23
+
21
24
  export interface TabsProps extends Omit<React.HTMLProps<HTMLElement | HTMLDivElement>, 'onSelect'>, OUIAProps {
22
- /** Content rendered inside the tabs component. Must be React.ReactElement<TabProps>[] */
23
- children: React.ReactNode;
25
+ /** Content rendered inside the tabs component. Only `Tab` components or expressions resulting in a falsy value are allowed here. */
26
+ children: TabsChild | TabsChild[];
24
27
  /** Additional classes added to the tabs */
25
28
  className?: string;
26
29
  /** Tabs background color variant */
@@ -163,8 +166,8 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
163
166
  // process any tab content sections outside of the component
164
167
  if (tabContentRef) {
165
168
  React.Children.toArray(this.props.children)
166
- .map(child => child as React.ReactElement<TabProps>)
167
- .filter(child => child.props && child.props.tabContentRef && child.props.tabContentRef.current)
169
+ .filter((child): child is TabElement => React.isValidElement(child))
170
+ .filter(({ props }) => props.tabContentRef && props.tabContentRef.current)
168
171
  .forEach(child => (child.props.tabContentRef.current.hidden = true));
169
172
  // most recently selected tabContent
170
173
  if (tabContentRef.current) {
@@ -308,8 +311,8 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
308
311
  uncontrolledActiveKey,
309
312
  uncontrolledIsExpandedLocal
310
313
  } = this.state;
311
- const filteredChildren = (React.Children.toArray(children) as React.ReactElement<TabProps>[])
312
- .filter(Boolean)
314
+ const filteredChildren = React.Children.toArray(children)
315
+ .filter((child): child is TabElement => React.isValidElement(child))
313
316
  .filter(child => !child.props.isHidden);
314
317
 
315
318
  const uniqueId = id || getUniqueId();