@patternfly/react-core 4.185.1 → 4.186.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.185.1",
3
+ "version": "4.186.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.36.1",
38
- "@patternfly/react-styles": "^4.35.1",
39
- "@patternfly/react-tokens": "^4.37.1",
37
+ "@patternfly/react-icons": "^4.37.0",
38
+ "@patternfly/react-styles": "^4.36.0",
39
+ "@patternfly/react-tokens": "^4.38.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": "430fd806b786f8869adfd434ea94b1e3b272d833"
63
+ "gitHead": "03e3df6771bae6c856dfb1d5a48397031cbfb37a"
64
64
  }
@@ -256,7 +256,8 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
256
256
  if (
257
257
  this.state.viewMoreNextIndex !== -1 &&
258
258
  this.refCollection.length > this.state.viewMoreNextIndex &&
259
- this.props.loadingVariant !== 'spinner'
259
+ this.props.loadingVariant !== 'spinner' &&
260
+ this.refCollection[this.state.viewMoreNextIndex][0]
260
261
  ) {
261
262
  this.refCollection[this.state.viewMoreNextIndex][0].focus();
262
263
  }
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
3
  import styles from '@patternfly/react-styles/css/components/ToggleGroup/toggle-group';
4
+ import { ToggleGroupItem } from './ToggleGroupItem';
4
5
 
5
6
  export interface ToggleGroupProps extends React.HTMLProps<HTMLDivElement> {
6
7
  /** Content rendered inside the toggle group */
@@ -9,6 +10,8 @@ export interface ToggleGroupProps extends React.HTMLProps<HTMLDivElement> {
9
10
  className?: string;
10
11
  /** Modifies the toggle group to include compact styling. */
11
12
  isCompact?: boolean;
13
+ /** Disable all toggle group items under this component. */
14
+ areAllGroupsDisabled?: boolean;
12
15
  /** Accessible label for the toggle group */
13
16
  'aria-label'?: string;
14
17
  }
@@ -17,12 +20,15 @@ export const ToggleGroup: React.FunctionComponent<ToggleGroupProps> = ({
17
20
  className,
18
21
  children,
19
22
  isCompact = false,
23
+ areAllGroupsDisabled = false,
20
24
  'aria-label': ariaLabel,
21
25
  ...props
22
26
  }: ToggleGroupProps) => {
23
- const toggleGroupItemList = [] as any[];
24
- React.Children.forEach(children, child => {
25
- toggleGroupItemList.push(child);
27
+ const toggleGroupItemList = React.Children.map(children, child => {
28
+ const childCompName = (child as any).type.name;
29
+ return childCompName !== ToggleGroupItem.name
30
+ ? child
31
+ : React.cloneElement(child as React.ReactElement, areAllGroupsDisabled ? { isDisabled: true } : {});
26
32
  });
27
33
 
28
34
  return (
@@ -71,9 +71,11 @@ exports[`isCompact 1`] = `
71
71
  role="group"
72
72
  >
73
73
  <ToggleGroupItem
74
+ key=".0"
74
75
  text="Test"
75
76
  />
76
77
  <ToggleGroupItem
78
+ key=".1"
77
79
  text="Test"
78
80
  />
79
81
  </div>
@@ -6,7 +6,7 @@ propComponents: ['ToggleGroup', 'ToggleGroupItem']
6
6
  ---
7
7
  import './toggleGroup.css';
8
8
 
9
- import { ToggleGroup, ToggleGroupItem} from '@patternfly/react-core';
9
+ import { ToggleGroup, ToggleGroupItem, Button, Stack, StackItem } from '@patternfly/react-core';
10
10
  import UndoIcon from '@patternfly/react-icons/dist/esm/icons/undo-icon';
11
11
  import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
12
12
  import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square-icon';
@@ -16,7 +16,7 @@ import ShareSquareIcon from '@patternfly/react-icons/dist/esm/icons/share-square
16
16
  ### Default with multiple selectable
17
17
  ```js
18
18
  import React from 'react';
19
- import { ToggleGroup, ToggleGroupItem } from '@patternfly/react-core';
19
+ import { ToggleGroup, ToggleGroupItem, Button, Stack, StackItem } from '@patternfly/react-core';
20
20
 
21
21
  class DefaultToggleGroupExample extends React.Component {
22
22
  constructor(props) {
@@ -24,7 +24,8 @@ class DefaultToggleGroupExample extends React.Component {
24
24
  this.state = {
25
25
  isSelected: {
26
26
  first: false,
27
- second: false
27
+ second: false,
28
+ disableAll: false
28
29
  }
29
30
  };
30
31
  this.handleItemClick = (isSelected, event) => {
@@ -36,17 +37,29 @@ class DefaultToggleGroupExample extends React.Component {
36
37
  };
37
38
  });
38
39
  };
40
+ this.disableAllClick = () => {
41
+ this.setState(prevState => ({ disableAll: !prevState.disableAll }));
42
+ };
39
43
  }
40
44
 
41
45
  render() {
42
46
  const { isSelected } = this.state;
43
47
 
44
48
  return (
45
- <ToggleGroup aria-label="Default with multiple selectable">
46
- <ToggleGroupItem text="Option 1" key={0} buttonId="first" isSelected={isSelected.first} onChange={this.handleItemClick} />
47
- <ToggleGroupItem text="Option 2" key={1} buttonId="second" isSelected={isSelected.second} onChange={this.handleItemClick} />
48
- <ToggleGroupItem text="Option 3" key={2} isDisabled/>
49
- </ToggleGroup>
49
+ <Stack hasGutter>
50
+ <StackItem>
51
+ <Button onClick={this.disableAllClick}>
52
+ {this.state.disableAll ? "Enable back" : "Disable all"}
53
+ </Button>
54
+ </StackItem>
55
+ <StackItem>
56
+ <ToggleGroup areAllGroupsDisabled={this.state.disableAll} aria-label="Default with multiple selectable">
57
+ <ToggleGroupItem text="Option 1" key={0} buttonId="first" isSelected={isSelected.first} onChange={this.handleItemClick} />
58
+ <ToggleGroupItem text="Option 2" key={1} buttonId="second" isSelected={isSelected.second} onChange={this.handleItemClick} />
59
+ <ToggleGroupItem text="Option 3" key={2} isDisabled/>
60
+ </ToggleGroup>
61
+ </StackItem>
62
+ </Stack>
50
63
  );
51
64
  }
52
65
  }