@patternfly/react-core 4.185.1 → 4.187.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 (35) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts +2 -0
  3. package/dist/esm/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
  4. package/dist/esm/components/ExpandableSection/ExpandableSection.js +3 -2
  5. package/dist/esm/components/ExpandableSection/ExpandableSection.js.map +1 -1
  6. package/dist/esm/components/Select/Select.d.ts.map +1 -1
  7. package/dist/esm/components/Select/Select.js +15 -8
  8. package/dist/esm/components/Select/Select.js.map +1 -1
  9. package/dist/esm/components/ToggleGroup/ToggleGroup.d.ts +2 -0
  10. package/dist/esm/components/ToggleGroup/ToggleGroup.d.ts.map +1 -1
  11. package/dist/esm/components/ToggleGroup/ToggleGroup.js +7 -4
  12. package/dist/esm/components/ToggleGroup/ToggleGroup.js.map +1 -1
  13. package/dist/js/components/ExpandableSection/ExpandableSection.d.ts +2 -0
  14. package/dist/js/components/ExpandableSection/ExpandableSection.d.ts.map +1 -1
  15. package/dist/js/components/ExpandableSection/ExpandableSection.js +3 -2
  16. package/dist/js/components/ExpandableSection/ExpandableSection.js.map +1 -1
  17. package/dist/js/components/Select/Select.d.ts.map +1 -1
  18. package/dist/js/components/Select/Select.js +15 -8
  19. package/dist/js/components/Select/Select.js.map +1 -1
  20. package/dist/js/components/ToggleGroup/ToggleGroup.d.ts +2 -0
  21. package/dist/js/components/ToggleGroup/ToggleGroup.d.ts.map +1 -1
  22. package/dist/js/components/ToggleGroup/ToggleGroup.js +7 -4
  23. package/dist/js/components/ToggleGroup/ToggleGroup.js.map +1 -1
  24. package/dist/umd/react-core.js +30 -20
  25. package/dist/umd/react-core.min.js +2 -2
  26. package/package.json +6 -6
  27. package/src/components/ExpandableSection/ExpandableSection.tsx +5 -0
  28. package/src/components/ExpandableSection/__tests__/ExpandableSection.test.tsx +5 -0
  29. package/src/components/ExpandableSection/__tests__/__snapshots__/ExpandableSection.test.tsx.snap +35 -0
  30. package/src/components/ExpandableSection/examples/ExpandableSection.md +35 -0
  31. package/src/components/Select/Select.tsx +19 -9
  32. package/src/components/Select/examples/Select.md +31 -13
  33. package/src/components/ToggleGroup/ToggleGroup.tsx +9 -3
  34. package/src/components/ToggleGroup/__tests__/__snapshots__/ToggleGroup.test.tsx.snap +2 -0
  35. package/src/components/ToggleGroup/examples/ToggleGroup.md +21 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.185.1",
3
+ "version": "4.187.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.36.1",
38
- "@patternfly/react-styles": "^4.35.1",
39
- "@patternfly/react-tokens": "^4.37.1",
37
+ "@patternfly/react-icons": "^4.38.1",
38
+ "@patternfly/react-styles": "^4.37.1",
39
+ "@patternfly/react-tokens": "^4.39.1",
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.166.3",
46
+ "@patternfly/patternfly": "4.166.4",
47
47
  "@rollup/plugin-commonjs": "^21.0.0",
48
48
  "@rollup/plugin-node-resolve": "^13.0.0",
49
49
  "@rollup/plugin-replace": "^3.0.0",
@@ -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": "3aaf05f6c91eac20f5bcdb775daa75e4e71eee92"
64
64
  }
@@ -29,6 +29,8 @@ export interface ExpandableSectionProps extends React.HTMLProps<HTMLDivElement>
29
29
  displaySize?: 'default' | 'large';
30
30
  /** Flag to indicate the width of the component is limited. Set to true for disclosure styling. */
31
31
  isWidthLimited?: boolean;
32
+ /** Flag to indicate if the content is indented */
33
+ isIndented?: boolean;
32
34
  }
33
35
 
34
36
  interface ExpandableSectionState {
@@ -56,6 +58,7 @@ export class ExpandableSection extends React.Component<ExpandableSectionProps, E
56
58
  isDetached: false,
57
59
  displaySize: 'default',
58
60
  isWidthLimited: false,
61
+ isIndented: false,
59
62
  contentId: ''
60
63
  };
61
64
 
@@ -88,6 +91,7 @@ export class ExpandableSection extends React.Component<ExpandableSectionProps, E
88
91
  isDetached,
89
92
  displaySize,
90
93
  isWidthLimited,
94
+ isIndented,
91
95
  contentId,
92
96
  ...props
93
97
  } = this.props;
@@ -119,6 +123,7 @@ export class ExpandableSection extends React.Component<ExpandableSectionProps, E
119
123
  isDetached && styles.modifiers.detached,
120
124
  displaySize === 'large' && styles.modifiers.displayLg,
121
125
  isWidthLimited && styles.modifiers.limitWidth,
126
+ isIndented && styles.modifiers.indented,
122
127
  className
123
128
  )}
124
129
  >
@@ -48,3 +48,8 @@ test('Disclosure ExpandableSection', () => {
48
48
  const view = shallow(<ExpandableSection {...props} displaySize="large" isWidthLimited>test </ExpandableSection>);
49
49
  expect(view).toMatchSnapshot();
50
50
  });
51
+
52
+ test('Renders ExpandableSection indented', () => {
53
+ const view = shallow(<ExpandableSection isExpanded isIndented> test </ExpandableSection>);
54
+ expect(view).toMatchSnapshot();
55
+ });
@@ -9,6 +9,7 @@ Array [
9
9
  isActive={false}
10
10
  isDetached={true}
11
11
  isExpanded={true}
12
+ isIndented={false}
12
13
  isWidthLimited={false}
13
14
  onToggle={[Function]}
14
15
  toggleText=""
@@ -182,6 +183,40 @@ exports[`Renders ExpandableSection expanded 1`] = `
182
183
  </div>
183
184
  `;
184
185
 
186
+ exports[`Renders ExpandableSection indented 1`] = `
187
+ <div
188
+ className="pf-c-expandable-section pf-m-expanded pf-m-indented"
189
+ >
190
+ <button
191
+ aria-expanded={true}
192
+ className="pf-c-expandable-section__toggle"
193
+ onClick={[Function]}
194
+ type="button"
195
+ >
196
+ <span
197
+ className="pf-c-expandable-section__toggle-icon"
198
+ >
199
+ <AngleRightIcon
200
+ aria-hidden={true}
201
+ color="currentColor"
202
+ noVerticalAlign={false}
203
+ size="sm"
204
+ />
205
+ </span>
206
+ <span
207
+ className="pf-c-expandable-section__toggle-text"
208
+ />
209
+ </button>
210
+ <div
211
+ className="pf-c-expandable-section__content"
212
+ hidden={false}
213
+ id=""
214
+ >
215
+ test
216
+ </div>
217
+ </div>
218
+ `;
219
+
185
220
  exports[`Renders Uncontrolled ExpandableSection 1`] = `
186
221
  <div
187
222
  className="pf-c-expandable-section"
@@ -143,3 +143,38 @@ class DisclosureExpandableSection extends React.Component {
143
143
  }
144
144
  }
145
145
  ```
146
+
147
+ ### Indented
148
+
149
+ ```js
150
+ import React from 'react';
151
+ import { ExpandableSection } from '@patternfly/react-core';
152
+
153
+ class SimpleExpandableSection extends React.Component {
154
+ constructor(props) {
155
+ super(props);
156
+ this.state = {
157
+ isExpanded: false
158
+ };
159
+ this.onToggle = isExpanded => {
160
+ this.setState({
161
+ isExpanded
162
+ });
163
+ };
164
+ }
165
+
166
+ render() {
167
+ const { isExpanded } = this.state;
168
+ return (
169
+ <ExpandableSection
170
+ toggleText={isExpanded ? 'Show less' : 'Show more'}
171
+ onToggle={this.onToggle}
172
+ isExpanded={isExpanded}
173
+ isIndented={true}
174
+ >
175
+ This content is visible only when the component is expanded.
176
+ </ExpandableSection>
177
+ );
178
+ }
179
+ }
180
+ ```
@@ -256,22 +256,32 @@ 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
  }
263
264
 
264
- // the number or contents of the children has changed, update state.typeaheadFilteredChildren
265
- if (
265
+ const hasUpdatedChildren =
266
266
  prevProps.children.length !== this.props.children.length ||
267
- prevProps.children.some((child: React.ReactElement, index: number) => {
268
- if (child.props && this.props.children[index].props) {
269
- return child.props.value !== this.props.children[index].props.value;
267
+ prevProps.children.some((prevChild: React.ReactElement, index: number) => {
268
+ const prevChildProps = prevChild.props;
269
+ const currChild = this.props.children[index];
270
+ const { props: currChildProps } = currChild;
271
+
272
+ if (prevChildProps && currChildProps) {
273
+ return (
274
+ prevChildProps.value !== currChildProps.value ||
275
+ prevChildProps.label !== currChildProps.label ||
276
+ prevChildProps.isDisabled !== currChildProps.isDisabled ||
277
+ prevChildProps.isPlaceholder !== currChildProps.isPlaceholder
278
+ );
270
279
  } else {
271
- return child !== this.props.children[index];
280
+ return prevChild !== currChild;
272
281
  }
273
- })
274
- ) {
282
+ });
283
+
284
+ if (hasUpdatedChildren) {
275
285
  this.updateTypeAheadFilteredChildren(prevState.typeaheadInputValue || '', null);
276
286
  }
277
287
 
@@ -348,7 +348,7 @@ class ValidatedSelect extends React.Component {
348
348
  console.log('selected:', selection);
349
349
  }
350
350
  this.setState({
351
- validated: validatedState
351
+ validated: validatedState
352
352
  });
353
353
  };
354
354
 
@@ -1183,13 +1183,13 @@ class TypeaheadSelectInput extends React.Component {
1183
1183
  constructor(props) {
1184
1184
  super(props);
1185
1185
  this.defaultOptions = [
1186
- { value: 'Alabama' },
1187
- { value: 'Florida', description: 'This is a description' },
1188
- { value: 'New Jersey' },
1189
- { value: 'New Mexico' },
1190
- { value: 'New York' },
1191
- { value: 'North Carolina' }
1192
- ];
1186
+ { value: 'Alabama' },
1187
+ { value: 'Florida', description: 'This is a description' },
1188
+ { value: 'New Jersey' },
1189
+ { value: 'New Mexico' },
1190
+ { value: 'New York' },
1191
+ { value: 'North Carolina' }
1192
+ ];
1193
1193
 
1194
1194
  this.state = {
1195
1195
  options: this.defaultOptions,
@@ -1579,7 +1579,8 @@ class MultiTypeaheadSelectInput extends React.Component {
1579
1579
  isOpen: false,
1580
1580
  selected: [],
1581
1581
  isCreatable: false,
1582
- hasOnCreateOption: false
1582
+ hasOnCreateOption: false,
1583
+ hasDisabledOption: false
1583
1584
  };
1584
1585
 
1585
1586
  this.onCreateOption = newValue => {
@@ -1627,10 +1628,19 @@ class MultiTypeaheadSelectInput extends React.Component {
1627
1628
  hasOnCreateOption: checked
1628
1629
  });
1629
1630
  };
1631
+
1632
+ this.toggleOptionDisabled = (toggleIndex) => () => {
1633
+ this.setState(prevState => ({
1634
+ hasDisabledOption: !prevState.hasDisabledOption,
1635
+ options: prevState.options.map((option, index) =>
1636
+ index === toggleIndex ? { ...option, disabled: !option.disabled } : option
1637
+ ),
1638
+ }));
1639
+ };
1630
1640
  }
1631
1641
 
1632
1642
  render() {
1633
- const { isOpen, selected, isCreatable, hasOnCreateOption } = this.state;
1643
+ const { isOpen, selected, isCreatable, hasOnCreateOption, options } = this.state;
1634
1644
  const titleId = 'multi-typeahead-select-id-1';
1635
1645
 
1636
1646
  return (
@@ -1651,7 +1661,7 @@ class MultiTypeaheadSelectInput extends React.Component {
1651
1661
  isCreatable={isCreatable}
1652
1662
  onCreateOption={(hasOnCreateOption && this.onCreateOption) || undefined}
1653
1663
  >
1654
- {this.state.options.map((option, index) => (
1664
+ {options.map((option, index) => (
1655
1665
  <SelectOption
1656
1666
  isDisabled={option.disabled}
1657
1667
  key={index}
@@ -1676,6 +1686,14 @@ class MultiTypeaheadSelectInput extends React.Component {
1676
1686
  id="toggle-new-typeahead-multi"
1677
1687
  name="toggle-new-typeahead-multi"
1678
1688
  />
1689
+ <Checkbox
1690
+ label="isDisabled (1st option only)"
1691
+ isChecked={this.state.hasDisabledOption}
1692
+ onChange={this.toggleOptionDisabled(0)}
1693
+ aria-label="toggle disable first option"
1694
+ id="toggle-disable-first-option"
1695
+ name="toggle-disable-first-option"
1696
+ />
1679
1697
  </div>
1680
1698
  );
1681
1699
  }
@@ -2453,7 +2471,7 @@ class SelectWithFooterCheckbox extends React.Component {
2453
2471
  Title
2454
2472
  </span>
2455
2473
  <Select
2456
- variant={SelectVariant.checkbox}
2474
+ variant={SelectVariant.checkbox}
2457
2475
  aria-label="Select input"
2458
2476
  onToggle={this.onToggle}
2459
2477
  onSelect={this.onSelect}
@@ -2578,7 +2596,7 @@ import {
2578
2596
  } from '@patternfly/react-core';
2579
2597
 
2580
2598
  class SelectViewMoreCheckbox extends React.Component {
2581
- constructor(props) {
2599
+ constructor(props) {
2582
2600
  super(props);
2583
2601
 
2584
2602
  this.state = {
@@ -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
  }