@patternfly/react-core 4.217.3 → 4.217.4
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/CHANGELOG.md +8 -0
- package/dist/esm/components/Switch/Switch.d.ts +9 -3
- package/dist/esm/components/Switch/Switch.d.ts.map +1 -1
- package/dist/esm/components/Switch/Switch.js +2 -2
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/js/components/Switch/Switch.d.ts +9 -3
- package/dist/js/components/Switch/Switch.d.ts.map +1 -1
- package/dist/js/components/Switch/Switch.js +2 -2
- package/dist/js/components/Switch/Switch.js.map +1 -1
- package/dist/umd/react-core.js +2 -2
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/Switch/Switch.tsx +12 -4
- package/src/components/Switch/examples/Switch.md +2 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.217.
|
|
3
|
+
"version": "4.217.4",
|
|
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.68.
|
|
38
|
-
"@patternfly/react-styles": "^4.67.
|
|
39
|
-
"@patternfly/react-tokens": "^4.69.
|
|
37
|
+
"@patternfly/react-icons": "^4.68.4",
|
|
38
|
+
"@patternfly/react-styles": "^4.67.4",
|
|
39
|
+
"@patternfly/react-tokens": "^4.69.4",
|
|
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": "
|
|
63
|
+
"gitHead": "ba782c2941a816480fc345e27ce9f15782a81298"
|
|
64
64
|
}
|
|
@@ -12,12 +12,18 @@ export interface SwitchProps
|
|
|
12
12
|
id?: string;
|
|
13
13
|
/** Additional classes added to the switch */
|
|
14
14
|
className?: string;
|
|
15
|
-
/** Text value for the label when on */
|
|
15
|
+
/** Text value for the visible label when on */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
|
-
/** Text value for the label when off */
|
|
17
|
+
/** Text value for the visible 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 when it is controlled by React state.
|
|
20
|
+
* To make the switch uncontrolled instead use the defaultChecked prop, but do not use both.
|
|
21
|
+
*/
|
|
20
22
|
isChecked?: boolean;
|
|
23
|
+
/** Flag to set the default checked value of the switch when it is uncontrolled by React state.
|
|
24
|
+
* To make the switch controlled instead use the isChecked prop, but do not use both.
|
|
25
|
+
*/
|
|
26
|
+
defaultChecked?: boolean;
|
|
21
27
|
/** Flag to show if the switch has a check icon. */
|
|
22
28
|
hasCheckIcon?: boolean;
|
|
23
29
|
/** Flag to show if the switch is disabled. */
|
|
@@ -63,6 +69,7 @@ export class Switch extends React.Component<SwitchProps & OUIAProps, { ouiaState
|
|
|
63
69
|
label,
|
|
64
70
|
labelOff,
|
|
65
71
|
isChecked,
|
|
72
|
+
defaultChecked,
|
|
66
73
|
hasCheckIcon,
|
|
67
74
|
isDisabled,
|
|
68
75
|
onChange,
|
|
@@ -84,7 +91,8 @@ export class Switch extends React.Component<SwitchProps & OUIAProps, { ouiaState
|
|
|
84
91
|
className={css(styles.switchInput)}
|
|
85
92
|
type="checkbox"
|
|
86
93
|
onChange={event => onChange(event.target.checked, event)}
|
|
87
|
-
|
|
94
|
+
{...([true, false].includes(defaultChecked) && { defaultChecked })}
|
|
95
|
+
{...(![true, false].includes(defaultChecked) && { checked: isChecked })}
|
|
88
96
|
disabled={isDisabled}
|
|
89
97
|
aria-labelledby={isAriaLabelledBy ? `${this.id}-on` : null}
|
|
90
98
|
{...props}
|
|
@@ -171,24 +171,8 @@ import React from 'react';
|
|
|
171
171
|
import { Switch } from '@patternfly/react-core';
|
|
172
172
|
|
|
173
173
|
<React.Fragment>
|
|
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
|
-
/>
|
|
181
|
-
<br />
|
|
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
|
-
/>
|
|
189
|
-
<br />
|
|
190
|
-
<Switch id="uncontrolled-no-label-switch-on" aria-label="Message when on" isChecked />
|
|
174
|
+
<Switch id="uncontrolled-switch-on" label="Message when on" labelOff="Message when off" defaultChecked={false} />
|
|
191
175
|
<br />
|
|
192
|
-
<Switch id="uncontrolled-no-label-switch-
|
|
176
|
+
<Switch id="uncontrolled-no-label-switch-on" aria-label="Message when on" defaultChecked={true} />
|
|
193
177
|
</React.Fragment>;
|
|
194
178
|
```
|