@patternfly/react-core 4.203.1 → 4.203.2

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.203.1",
3
+ "version": "4.203.2",
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.54.1",
38
- "@patternfly/react-styles": "^4.53.1",
39
- "@patternfly/react-tokens": "^4.55.1",
37
+ "@patternfly/react-icons": "^4.54.2",
38
+ "@patternfly/react-styles": "^4.53.2",
39
+ "@patternfly/react-tokens": "^4.55.2",
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.187.0",
46
+ "@patternfly/patternfly": "4.190.0",
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": "2f16e9b81a8ab2c54d9ef945e50c1e4aa7510c49"
63
+ "gitHead": "ca5c716646e391e92b954b9cb3bbbe52b16834b7"
64
64
  }
@@ -9,8 +9,10 @@ export interface FormProps extends React.HTMLProps<HTMLFormElement> {
9
9
  className?: string;
10
10
  /** Sets the Form to horizontal. */
11
11
  isHorizontal?: boolean;
12
- /** Flag to limit the max-width to 500px. */
12
+ /** Limits the max-width of the form. */
13
13
  isWidthLimited?: boolean;
14
+ /** Sets a custom max-width for the form. */
15
+ maxWidth?: string;
14
16
  }
15
17
 
16
18
  export const Form: React.FunctionComponent<FormProps> = ({
@@ -18,15 +20,22 @@ export const Form: React.FunctionComponent<FormProps> = ({
18
20
  className = '',
19
21
  isHorizontal = false,
20
22
  isWidthLimited = false,
23
+ maxWidth = '',
21
24
  ...props
22
25
  }: FormProps) => (
23
26
  <form
24
27
  noValidate
28
+ {...(maxWidth && {
29
+ style: {
30
+ '--pf-c-form--m-limit-width--MaxWidth': maxWidth,
31
+ ...props.style
32
+ } as React.CSSProperties
33
+ })}
25
34
  {...props}
26
35
  className={css(
27
36
  styles.form,
28
37
  isHorizontal && styles.modifiers.horizontal,
29
- isWidthLimited && styles.modifiers.limitWidth,
38
+ (isWidthLimited || maxWidth) && styles.modifiers.limitWidth,
30
39
  className
31
40
  )}
32
41
  >
@@ -10,19 +10,21 @@ export interface SwitchProps
10
10
  OUIAProps {
11
11
  /** id for the label. */
12
12
  id?: string;
13
- /** Additional classes added to the Switch */
13
+ /** Additional classes added to the switch */
14
14
  className?: string;
15
15
  /** Text value for the label when on */
16
16
  label?: React.ReactNode;
17
17
  /** Text value for the label when off */
18
18
  labelOff?: React.ReactNode;
19
- /** Flag to show if the Switch is checked. */
19
+ /** Flag to show if the switch is checked. */
20
20
  isChecked?: boolean;
21
- /** Flag to show if the Switch is disabled. */
21
+ /** Flag to show if the switch has a check icon. */
22
+ hasCheckIcon?: boolean;
23
+ /** Flag to show if the switch is disabled. */
22
24
  isDisabled?: boolean;
23
- /** A callback for when the Switch selection changes. (isChecked, event) => {} */
25
+ /** A callback for when the switch selection changes. (isChecked, event) => {} */
24
26
  onChange?: (checked: boolean, event: React.FormEvent<HTMLInputElement>) => void;
25
- /** Adds accessible text to the Switch, and should describe the isChecked="true" state. When label is defined, aria-label should be set to the text string that is visible when isChecked is true. */
27
+ /** Adds accessible text to the switch, and should describe the isChecked="true" state. When label is defined, aria-label should be set to the text string that is visible when isChecked is true. */
26
28
  'aria-label'?: string;
27
29
  /** Flag to reverse the layout of toggle and label (toggle on right). */
28
30
  isReversed?: boolean;
@@ -61,6 +63,7 @@ export class Switch extends React.Component<SwitchProps & OUIAProps, { ouiaState
61
63
  label,
62
64
  labelOff,
63
65
  isChecked,
66
+ hasCheckIcon,
64
67
  isDisabled,
65
68
  onChange,
66
69
  isReversed,
@@ -96,6 +99,11 @@ export class Switch extends React.Component<SwitchProps & OUIAProps, { ouiaState
96
99
  >
97
100
  {label}
98
101
  </span>
102
+ {hasCheckIcon && (
103
+ <div className={css(styles.switchToggleIcon)} aria-hidden="true">
104
+ <CheckIcon noVerticalAlign />
105
+ </div>
106
+ )}
99
107
  <span
100
108
  className={css(styles.switchLabel, styles.modifiers.off)}
101
109
  id={isAriaLabelledBy ? `${this.id}-off` : null}
@@ -7,7 +7,9 @@ ouia: true
7
7
  ---
8
8
 
9
9
  ## Examples
10
+
10
11
  ### Basic
12
+
11
13
  ```js
12
14
  import React from 'react';
13
15
  import { Switch } from '@patternfly/react-core';
@@ -39,6 +41,7 @@ class SimpleSwitch extends React.Component {
39
41
  ```
40
42
 
41
43
  ### Reversed Layout
44
+
42
45
  ```js
43
46
  import React from 'react';
44
47
  import { Switch } from '@patternfly/react-core';
@@ -71,6 +74,7 @@ class ReversedSwitch extends React.Component {
71
74
  ```
72
75
 
73
76
  ### Without label
77
+
74
78
  ```js
75
79
  import React from 'react';
76
80
  import { Switch } from '@patternfly/react-core';
@@ -95,13 +99,55 @@ class NoLabelSwitch extends React.Component {
95
99
  }
96
100
  ```
97
101
 
102
+ ### Checked with label
103
+
104
+ ```js
105
+ import React from 'react';
106
+ import { Switch } from '@patternfly/react-core';
107
+
108
+ class CheckedWithLabelSwitch extends React.Component {
109
+ constructor(props) {
110
+ super(props);
111
+ this.state = {
112
+ isChecked: true
113
+ };
114
+ this.handleChange = isChecked => {
115
+ this.setState({ isChecked });
116
+ };
117
+ }
118
+
119
+ render() {
120
+ const { isChecked } = this.state;
121
+ return (
122
+ <Switch
123
+ label="Message when on"
124
+ labelOff="Message when off"
125
+ id="checked-with-label-switch-on"
126
+ aria-label="Message when on"
127
+ isChecked={isChecked}
128
+ hasCheckIcon
129
+ onChange={this.handleChange}
130
+ />
131
+ );
132
+ }
133
+ }
134
+ ```
135
+
98
136
  ### Disabled
137
+
99
138
  ```js
100
139
  import React from 'react';
101
140
  import { Switch } from '@patternfly/react-core';
102
141
 
103
142
  <React.Fragment>
104
- <Switch id="disabled-switch-on" aria-label="Message when on" label="Message when on" labelOff="Message when off" isChecked isDisabled />
143
+ <Switch
144
+ id="disabled-switch-on"
145
+ aria-label="Message when on"
146
+ label="Message when on"
147
+ labelOff="Message when off"
148
+ isChecked
149
+ isDisabled
150
+ />
105
151
  <br />
106
152
  <Switch
107
153
  id="disabled-switch-off"
@@ -115,21 +161,34 @@ import { Switch } from '@patternfly/react-core';
115
161
  <Switch id="disabled-no-label-switch-on" aria-label="Message when on" isChecked isDisabled />
116
162
  <br />
117
163
  <Switch id="disabled-no-label-switch-off" aria-label="Message when on" isChecked={false} isDisabled />
118
- </React.Fragment>
164
+ </React.Fragment>;
119
165
  ```
120
166
 
121
167
  ### Uncontrolled
168
+
122
169
  ```js
123
170
  import React from 'react';
124
171
  import { Switch } from '@patternfly/react-core';
125
172
 
126
173
  <React.Fragment>
127
- <Switch id="uncontrolled-switch-on" aria-label="Message when on" label="Message when on" labelOff="Message when off" isChecked />
174
+ <Switch
175
+ id="uncontrolled-switch-on"
176
+ aria-label="Message when on"
177
+ label="Message when on"
178
+ labelOff="Message when off"
179
+ isChecked
180
+ />
128
181
  <br />
129
- <Switch id="uncontrolled-switch-off" aria-label="Message when on" label="Message when on" labelOff="Message when off" isChecked={false} />
182
+ <Switch
183
+ id="uncontrolled-switch-off"
184
+ aria-label="Message when on"
185
+ label="Message when on"
186
+ labelOff="Message when off"
187
+ isChecked={false}
188
+ />
130
189
  <br />
131
190
  <Switch id="uncontrolled-no-label-switch-on" aria-label="Message when on" isChecked />
132
191
  <br />
133
192
  <Switch id="uncontrolled-no-label-switch-off" aria-label="Message when on" isChecked={false} />
134
- </React.Fragment>
193
+ </React.Fragment>;
135
194
  ```
@@ -20,7 +20,7 @@ Toolbar items are individual components that can be placed inside of a toolbar.
20
20
  ```js
21
21
  import React from 'react';
22
22
  import { Toolbar, ToolbarItem, ToolbarContent } from '@patternfly/react-core';
23
- import { Button, ButtonVariant, InputGroup, SearchInput } from '@patternfly/react-core';
23
+ import { Button, SearchInput } from '@patternfly/react-core';
24
24
 
25
25
  class ToolbarItems extends React.Component {
26
26
  constructor(props) {
@@ -133,7 +133,7 @@ class ToolbarSpacers extends React.Component {
133
133
 
134
134
  ```js
135
135
  import React from 'react';
136
- import { Toolbar, ToolbarItem, ToolbarGroup, ToolbarContent } from '@patternfly/react-core';
136
+ import { Toolbar, ToolbarItem, ToolbarContent } from '@patternfly/react-core';
137
137
  import { Button } from '@patternfly/react-core';
138
138
 
139
139
  class ToolbarWidths extends React.Component {
@@ -237,16 +237,7 @@ class ToolbarSpacers extends React.Component {
237
237
 
238
238
  ```js
239
239
  import React from 'react';
240
- import {
241
- Toolbar,
242
- ToolbarItem,
243
- ToolbarContent,
244
- Button,
245
- ButtonVariant,
246
- InputGroup,
247
- TextInput,
248
- Checkbox
249
- } from '@patternfly/react-core';
240
+ import { Toolbar, ToolbarItem, ToolbarContent, SearchInput, Checkbox } from '@patternfly/react-core';
250
241
  import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
251
242
 
252
243
  const ToolbarItems = () => {
@@ -261,12 +252,7 @@ const ToolbarItems = () => {
261
252
  <Toolbar id="toolbar-spacers" inset={{ default: 'insetNone' }} isSticky={isSticky}>
262
253
  <ToolbarContent>
263
254
  <ToolbarItem>
264
- <InputGroup>
265
- <TextInput name="textInput1" id="textInput1" type="search" aria-label="search input example" />
266
- <Button variant={ButtonVariant.control} aria-label="search button for search input">
267
- <SearchIcon />
268
- </Button>
269
- </InputGroup>
255
+ <SearchInput aria-label="search input example" />
270
256
  </ToolbarItem>
271
257
  <ToolbarItem>
272
258
  <Checkbox
@@ -500,15 +486,7 @@ A toggle group can be used when you want to collapse a set of items into an over
500
486
  ```js
501
487
  import React from 'react';
502
488
  import { Toolbar, ToolbarItem, ToolbarContent, ToolbarToggleGroup, ToolbarGroup } from '@patternfly/react-core';
503
- import {
504
- Button,
505
- ButtonVariant,
506
- InputGroup,
507
- Select,
508
- SelectOption,
509
- SelectVariant,
510
- SearchInput
511
- } from '@patternfly/react-core';
489
+ import { Select, SelectOption, SelectVariant, SearchInput } from '@patternfly/react-core';
512
490
  import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
513
491
 
514
492
  class ToolbarComponentMangedToggleGroup extends React.Component {
@@ -659,18 +637,10 @@ If the consumer would prefer to manage the expanded state of the toggle group fo
659
637
  ```js
660
638
  import React from 'react';
661
639
  import { Toolbar, ToolbarItem, ToolbarContent, ToolbarToggleGroup, ToolbarGroup } from '@patternfly/react-core';
662
- import {
663
- Button,
664
- ButtonVariant,
665
- InputGroup,
666
- Select,
667
- SelectOption,
668
- SelectVariant,
669
- SearchInput
670
- } from '@patternfly/react-core';
640
+ import { Select, SelectOption, SelectVariant, SearchInput } from '@patternfly/react-core';
671
641
  import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
672
642
 
673
- class ToolbarConsumerMangedToggleGroup extends React.Component {
643
+ class ToolbarConsumerManagedToggleGroup extends React.Component {
674
644
  constructor(props) {
675
645
  super(props);
676
646
  this.state = {
@@ -835,8 +805,6 @@ import {
835
805
  } from '@patternfly/react-core';
836
806
  import {
837
807
  Button,
838
- ButtonVariant,
839
- InputGroup,
840
808
  Select,
841
809
  SelectOption,
842
810
  SelectVariant,