@patternfly/react-core 4.186.0 → 4.186.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.186.0",
3
+ "version": "4.186.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,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.37.0",
38
- "@patternfly/react-styles": "^4.36.0",
39
- "@patternfly/react-tokens": "^4.38.0",
37
+ "@patternfly/react-icons": "^4.37.1",
38
+ "@patternfly/react-styles": "^4.36.1",
39
+ "@patternfly/react-tokens": "^4.38.1",
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": "03e3df6771bae6c856dfb1d5a48397031cbfb37a"
63
+ "gitHead": "004cdf8648be921f15c9dafa489964f4bc4fa8d5"
64
64
  }
@@ -262,17 +262,26 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
262
262
  this.refCollection[this.state.viewMoreNextIndex][0].focus();
263
263
  }
264
264
 
265
- // the number or contents of the children has changed, update state.typeaheadFilteredChildren
266
- if (
265
+ const hasUpdatedChildren =
267
266
  prevProps.children.length !== this.props.children.length ||
268
- prevProps.children.some((child: React.ReactElement, index: number) => {
269
- if (child.props && this.props.children[index].props) {
270
- 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
+ );
271
279
  } else {
272
- return child !== this.props.children[index];
280
+ return prevChild !== currChild;
273
281
  }
274
- })
275
- ) {
282
+ });
283
+
284
+ if (hasUpdatedChildren) {
276
285
  this.updateTypeAheadFilteredChildren(prevState.typeaheadInputValue || '', null);
277
286
  }
278
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 = {