@patternfly/react-core 4.184.2 → 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/CHANGELOG.md +41 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +15 -8
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/ToggleGroup/ToggleGroup.d.ts +2 -0
- package/dist/esm/components/ToggleGroup/ToggleGroup.d.ts.map +1 -1
- package/dist/esm/components/ToggleGroup/ToggleGroup.js +7 -4
- package/dist/esm/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +15 -8
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/ToggleGroup/ToggleGroup.d.ts +2 -0
- package/dist/js/components/ToggleGroup/ToggleGroup.d.ts.map +1 -1
- package/dist/js/components/ToggleGroup/ToggleGroup.js +7 -4
- package/dist/js/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/umd/react-core.css +143 -143
- package/dist/umd/react-core.js +27 -18
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/Select/Select.tsx +19 -9
- package/src/components/Select/examples/Select.md +31 -13
- package/src/components/ToggleGroup/ToggleGroup.tsx +9 -3
- package/src/components/ToggleGroup/__tests__/__snapshots__/ToggleGroup.test.tsx.snap +2 -0
- 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.
|
|
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.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
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": "
|
|
63
|
+
"gitHead": "004cdf8648be921f15c9dafa489964f4bc4fa8d5"
|
|
64
64
|
}
|
|
@@ -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
|
-
|
|
265
|
-
if (
|
|
265
|
+
const hasUpdatedChildren =
|
|
266
266
|
prevProps.children.length !== this.props.children.length ||
|
|
267
|
-
prevProps.children.some((
|
|
268
|
-
|
|
269
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
24
|
-
|
|
25
|
-
|
|
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 (
|
|
@@ -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
|
-
<
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
}
|