@patternfly/react-core 4.237.5 → 4.237.6

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.237.5",
3
+ "version": "4.237.6",
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",
@@ -44,9 +44,9 @@
44
44
  "generate": "node scripts/copyStyles.js"
45
45
  },
46
46
  "dependencies": {
47
- "@patternfly/react-icons": "^4.88.5",
48
- "@patternfly/react-styles": "^4.87.5",
49
- "@patternfly/react-tokens": "^4.89.5",
47
+ "@patternfly/react-icons": "^4.88.6",
48
+ "@patternfly/react-styles": "^4.87.6",
49
+ "@patternfly/react-tokens": "^4.89.6",
50
50
  "focus-trap": "6.9.2",
51
51
  "react-dropzone": "9.0.0",
52
52
  "tippy.js": "5.1.2",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8.0 || ^17.0.0",
71
71
  "react-dom": "^16.8.0 || ^17.0.0"
72
72
  },
73
- "gitHead": "418c3382f60536603adfb5b23d41dfbe03ddca39"
73
+ "gitHead": "55fff2303d14e704bf9c55a5d5f2866e16a83a05"
74
74
  }
@@ -3,20 +3,23 @@ import styles from '@patternfly/react-styles/css/components/Check/check';
3
3
  import { css } from '@patternfly/react-styles';
4
4
  import { PickOptional } from '../../helpers/typeUtils';
5
5
  import { getDefaultOUIAId, getOUIAProps, OUIAProps } from '../../helpers';
6
+ import { ASTERISK } from '../../helpers/htmlConstants';
6
7
 
7
8
  export interface CheckboxProps
8
9
  extends Omit<React.HTMLProps<HTMLInputElement>, 'type' | 'onChange' | 'disabled' | 'label'>,
9
10
  OUIAProps {
10
- /** Additional classes added to the Checkbox. */
11
+ /** Additional classes added to the checkbox. */
11
12
  className?: string;
12
- /** Flag to show if the Checkbox selection is valid or invalid. */
13
+ /** Flag to show if the checkbox selection is valid or invalid. */
13
14
  isValid?: boolean;
14
- /** Flag to show if the Checkbox is disabled. */
15
+ /** Flag to show if the checkbox is disabled. */
15
16
  isDisabled?: boolean;
16
- /** Flag to show if the Checkbox is checked. If null, the checkbox will be indeterminate (partially checked). */
17
+ /** Flag to show if the checkbox is required. */
18
+ isRequired?: boolean;
19
+ /** Flag to show if the checkbox is checked. If null, the checkbox will be indeterminate (partially checked). */
17
20
  isChecked?: boolean | null;
18
21
  checked?: boolean;
19
- /** A callback for when the Checkbox selection changes. */
22
+ /** A callback for when the checkbox selection changes. */
20
23
  onChange?: (checked: boolean, event: React.FormEvent<HTMLInputElement>) => void;
21
24
  /** Label text of the checkbox. */
22
25
  label?: React.ReactNode;
@@ -45,6 +48,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
45
48
  className: '',
46
49
  isValid: true,
47
50
  isDisabled: false,
51
+ isRequired: false,
48
52
  isChecked: false,
49
53
  onChange: defaultOnChange,
50
54
  ouiaSafe: true,
@@ -69,6 +73,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
69
73
  onChange,
70
74
  isValid,
71
75
  isDisabled,
76
+ isRequired,
72
77
  isChecked,
73
78
  label,
74
79
  checked,
@@ -106,6 +111,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
106
111
  aria-invalid={!isValid}
107
112
  aria-label={ariaLabel}
108
113
  disabled={isDisabled}
114
+ required={isRequired}
109
115
  ref={elem => elem && (elem.indeterminate = isChecked === null)}
110
116
  {...checkedProps}
111
117
  {...getOUIAProps(Checkbox.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe)}
@@ -113,6 +119,11 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
113
119
  {label && (
114
120
  <label className={css(styles.checkLabel, isDisabled && styles.modifiers.disabled)} htmlFor={props.id}>
115
121
  {label}
122
+ {isRequired && (
123
+ <span className={css(styles.checkLabelRequired)} aria-hidden="true">
124
+ {ASTERISK}
125
+ </span>
126
+ )}
116
127
  </label>
117
128
  )}
118
129
  {description && <span className={css(styles.checkDescription)}>{description}</span>}
@@ -43,3 +43,8 @@ import './checkbox.css';
43
43
 
44
44
  ```ts file='./CheckboxStandaloneInput.tsx'
45
45
  ```
46
+
47
+ ### Required input
48
+
49
+ ```ts file='./CheckboxRequired.tsx'
50
+ ```
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Checkbox } from '@patternfly/react-core';
3
+
4
+ export const CheckboxRequired: React.FunctionComponent = () => (
5
+ <Checkbox label="Required checkbox" isRequired id="required-check" name="required-check" />
6
+ );
@@ -20,12 +20,15 @@ class DefaultTreeView extends React.Component {
20
20
  constructor(props) {
21
21
  super(props);
22
22
 
23
- this.state = { activeItems: {}, allExpanded: null };
23
+ this.state = { activeItems: [], allExpanded: null };
24
24
 
25
25
  this.onSelect = (evt, treeViewItem) => {
26
- this.setState({
27
- activeItems: [treeViewItem]
28
- });
26
+ // Ignore folders for selection
27
+ if (treeViewItem && !treeViewItem.children) {
28
+ this.setState({
29
+ activeItems: [treeViewItem]
30
+ });
31
+ }
29
32
  };
30
33
 
31
34
  this.onToggle = evt => {
@@ -288,9 +291,12 @@ class SearchTreeView extends React.Component {
288
291
  this.state = { activeItems: {}, filteredItems: this.options, isFiltered: null };
289
292
 
290
293
  this.onSelect = (evt, treeViewItem) => {
291
- this.setState({
292
- activeItems: [treeViewItem]
293
- });
294
+ // Ignore folders for selection
295
+ if (treeViewItem && !treeViewItem.children) {
296
+ this.setState({
297
+ activeItems: [treeViewItem]
298
+ });
299
+ }
294
300
  };
295
301
 
296
302
  this.onSearch = evt => {
@@ -575,9 +581,12 @@ class IconTreeView extends React.Component {
575
581
  this.state = { activeItems: {} };
576
582
 
577
583
  this.onSelect = (evt, treeViewItem) => {
578
- this.setState({
579
- activeItems: [treeViewItem]
580
- });
584
+ // Ignore folders for selection
585
+ if (treeViewItem && !treeViewItem.children) {
586
+ this.setState({
587
+ activeItems: [treeViewItem]
588
+ });
589
+ }
581
590
  };
582
591
  }
583
592
 
@@ -668,9 +677,12 @@ class BadgesTreeView extends React.Component {
668
677
  this.state = { activeItems: {} };
669
678
 
670
679
  this.onSelect = (evt, treeViewItem) => {
671
- this.setState({
672
- activeItems: [treeViewItem]
673
- });
680
+ // Ignore folders for selection
681
+ if (treeViewItem && !treeViewItem.children) {
682
+ this.setState({
683
+ activeItems: [treeViewItem]
684
+ });
685
+ }
674
686
  };
675
687
  }
676
688
 
@@ -753,9 +765,12 @@ class CustomBadgesTreeView extends React.Component {
753
765
  this.state = { activeItems: {} };
754
766
 
755
767
  this.onSelect = (evt, treeViewItem) => {
756
- this.setState({
757
- activeItems: [treeViewItem]
758
- });
768
+ // Ignore folders for selection
769
+ if (treeViewItem && !treeViewItem.children) {
770
+ this.setState({
771
+ activeItems: [treeViewItem]
772
+ });
773
+ }
759
774
  };
760
775
  }
761
776
 
@@ -853,9 +868,12 @@ class IconTreeView extends React.Component {
853
868
  this.state = { activeItems: {}, isOpen: false };
854
869
 
855
870
  this.onSelect = (evt, treeViewItem) => {
856
- this.setState({
857
- activeItems: [treeViewItem]
858
- });
871
+ // Ignore folders for selection
872
+ if (treeViewItem && !treeViewItem.children) {
873
+ this.setState({
874
+ activeItems: [treeViewItem]
875
+ });
876
+ }
859
877
  };
860
878
 
861
879
  this.onToggle = isOpen => {